This is an automated email from the ASF dual-hosted git repository.
jameshartig pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-gocql-driver.git
The following commit(s) were added to refs/heads/trunk by this push:
new c0cefb08 <framer> optimization `writeHeader(...)` method
c0cefb08 is described below
commit c0cefb0858f40dc2899c483221e8cc91cdd8afc0
Author: illia-li <[email protected]>
AuthorDate: Mon Apr 14 13:26:10 2025 -0400
<framer> optimization `writeHeader(...)` method
Fixes:
* splits all `append` operations in one
Patch by illia-li; reviewed by ... for CASSGO-...
---
frame.go | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/frame.go b/frame.go
index 4ba28bdf..c3b9606b 100644
--- a/frame.go
+++ b/frame.go
@@ -700,31 +700,19 @@ func (f *framer) readErrorMap() (errMap ErrorMap) {
}
func (f *framer) writeHeader(flags byte, op frameOp, stream int) {
- f.buf = f.buf[:0]
- f.buf = append(f.buf,
- f.proto,
- flags,
- )
-
- if f.proto > protoVersion2 {
- f.buf = append(f.buf,
- byte(stream>>8),
- byte(stream),
+ if f.proto <= protoVersion2 {
+ f.buf = append(f.buf[:0],
+ f.proto, flags, byte(stream),
+ // pad out length
+ byte(op), 0, 0, 0, 0,
)
} else {
- f.buf = append(f.buf,
- byte(stream),
+ f.buf = append(f.buf[:0],
+ f.proto, flags, byte(stream>>8), byte(stream),
+ // pad out length
+ byte(op), 0, 0, 0, 0,
)
}
-
- // pad out length
- f.buf = append(f.buf,
- byte(op),
- 0,
- 0,
- 0,
- 0,
- )
}
func (f *framer) setLength(length int) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]