-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
【建议】压缩int的时候,如果是负数,现在实现中的压缩结果有点浪费空间 #69
Comments
And how do you know the To be honest, when MMKV was started, the encoding/decoding code was inspired by the Google official implementation, which will sign-extend negative numbers. If there's a huge call for negative number handling, maybe we should add some |
If we zigzag all positive and negative numbers, we do not have to care if a number is negative. Just un-zigzag all numbers |
And that’s a big if, for breaking existing code/data that relying on not zigzaging positive numbers. You gota think about backward compatibility. |
void CodedOutputData::writeInt32(int32_t value) { if (value >= 0) { this->writeRawVarint32(value); } else { this->writeRawVarint64(value); } }
不明白为什么要采用现在这种压缩方法。
zigzag 压缩负数的效率应该比 writeRawVarint64 的实现要好一些
The text was updated successfully, but these errors were encountered: