-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add RawKey function and make use of it. #56
Conversation
It looks like I broke something. Will fix. |
Avoids some unnecessary creation of strings.
f7a1aaa
to
f397865
Compare
Should be fixed now. |
@whyrusleeping should be good to go |
@@ -29,8 +28,8 @@ func PrefixTransform(prefix ds.Key) ktds.KeyTransform { | |||
panic("expected prefix not found") | |||
} | |||
|
|||
s := strings.TrimPrefix(k.String(), prefix.String()) | |||
return ds.NewKey(s) | |||
s := k.String()[len(prefix.String()):] |
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.
You should make sure to do a bounds check here.
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.
I could but then what, panic. Also it is redundant because if prefix.IsAncestorOf passes then there is no way for this to be out of bounds.
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.
Ah, i see. I didnt realize we already had that expectation here.
LGTM, thanks!` |
Avoids some unnecessary creation of strings.
This decreased the time to retrieve 100,000 small (1000 byte) blocks (see ipfs/kubo#3376) from around 245 ms to 205 ms.