-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement preallocated buffer #996
Changes from 20 commits
fe89341
f9f508c
6f3144d
a04f3bd
96e6ac2
d4aa567
2f56ace
b2aed3d
5285c7e
96528de
0b17def
ca10f22
9d07d54
4cf3040
7fa634f
ab2a884
cb7f6e5
250e136
9e149d3
02b25c7
574bb0a
37159fc
2e75e11
42817f8
8d996ba
333e8c5
589e03d
7055c56
ccc2b55
9760ab2
44e998b
b76f897
5a7d172
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,18 @@ func (v *ValueStruct) EncodeTo(buf *bytes.Buffer) { | |
buf.Write(v.Value) | ||
} | ||
|
||
// EncodeTo should be kept in sync with the Encode function above. The reason | ||
// this function exists is to avoid creating byte arrays per key-value pair in | ||
// table/builder.go. | ||
func (v *ValueStruct) EncodeToYBuf(buf *Buffer) { | ||
buf.WriteByte(v.Meta) | ||
buf.WriteByte(v.UserMeta) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error return value of |
||
var enc [binary.MaxVarintLen64]byte | ||
sz := binary.PutUvarint(enc[:], v.ExpiresAt) | ||
buf.Write(enc[:sz]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error return value of |
||
buf.Write(v.Value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error return value of |
||
} | ||
|
||
// Iterator is an interface for a basic iterator. | ||
type Iterator interface { | ||
Next() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error return value of
buf.WriteByte
is not checked (fromerrcheck
)