Skip to content

Commit 17788e3

Browse files
committed
<framer> optimization readTrace()
Changes: * `readTrace()` cleaned from conversion `[]byte`->`UUID`->`[]byte` * `readUUID()` deleted
1 parent 0c52dc7 commit 17788e3

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

frame.go

+5-12
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,11 @@ func (f *framer) writeTo(w io.Writer) error {
827827
}
828828

829829
func (f *framer) readTrace() {
830-
f.traceID = f.readUUID().Bytes()
830+
if len(f.buf) < 16 {
831+
panic(fmt.Errorf("not enough bytes in buffer to read trace uuid require 16 got: %d", len(f.buf)))
832+
}
833+
copy(f.traceID, f.buf[:16])
834+
f.buf = f.buf[16:]
831835
}
832836

833837
type readyFrame struct {
@@ -1861,17 +1865,6 @@ func (f *framer) readLongString() (s string) {
18611865
return
18621866
}
18631867

1864-
func (f *framer) readUUID() *UUID {
1865-
if len(f.buf) < 16 {
1866-
panic(fmt.Errorf("not enough bytes in buffer to read uuid require %d got: %d", 16, len(f.buf)))
1867-
}
1868-
1869-
// TODO: how to handle this error, if it is a uuid, then sureley, problems?
1870-
u, _ := UUIDFromBytes(f.buf[:16])
1871-
f.buf = f.buf[16:]
1872-
return &u
1873-
}
1874-
18751868
func (f *framer) readStringList() []string {
18761869
size := f.readShort()
18771870

0 commit comments

Comments
 (0)