Skip to content

Commit 5f4d36a

Browse files
illia-lijameshartig
authored andcommitted
<framer> optimization readTrace() method
Fixes: * method `readTrace()` cleaned from unnecessary conversion `[]byte`->`UUID`->`[]byte` * method `readUUID()` deleted because unused Patch by illia-li; reviewed by ... for CASSGO-...
1 parent 0551773 commit 5f4d36a

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

frame.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,14 @@ func (f *framer) writeTo(w io.Writer) error {
771771
}
772772

773773
func (f *framer) readTrace() {
774-
f.traceID = f.readUUID().Bytes()
774+
if len(f.buf) < 16 {
775+
panic(fmt.Errorf("not enough bytes in buffer to read trace uuid require 16 got: %d", len(f.buf)))
776+
}
777+
if len(f.traceID) != 16 {
778+
f.traceID = make([]byte, 16)
779+
}
780+
copy(f.traceID, f.buf[:16])
781+
f.buf = f.buf[16:]
775782
}
776783

777784
type readyFrame struct {
@@ -1876,17 +1883,6 @@ func (f *framer) readLongString() (s string) {
18761883
return
18771884
}
18781885

1879-
func (f *framer) readUUID() *UUID {
1880-
if len(f.buf) < 16 {
1881-
panic(fmt.Errorf("not enough bytes in buffer to read uuid require %d got: %d", 16, len(f.buf)))
1882-
}
1883-
1884-
// TODO: how to handle this error, if it is a uuid, then sureley, problems?
1885-
u, _ := UUIDFromBytes(f.buf[:16])
1886-
f.buf = f.buf[16:]
1887-
return &u
1888-
}
1889-
18901886
func (f *framer) readStringList() []string {
18911887
size := f.readShort()
18921888

0 commit comments

Comments
 (0)