-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Support nulls in String compare, CreateSharedString #5060
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
Conversation
f8e2fd7 to
9a0a286
Compare
|
Let me know if you prefer using |
aardappel
left a comment
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.
Thanks for the fix!
include/flatbuffers/flatbuffers.h
Outdated
| // return true if the first is less than the second. | ||
| static inline bool StringLessThan(const char* aData, uoffset_t aSize, | ||
| const char* bData, uoffset_t bSize) | ||
| { |
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.
Please use same style as rest of the file, { on previous line, snake_case instead of camelCase, * on the right etc.
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 still see plenty of code that doesn't match the code style in the tests. Please have a look.
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.
Finished style fixes for tests.
include/flatbuffers/flatbuffers.h
Outdated
| { | ||
| const auto cmp = memcmp(aData, bData, (std::min)(aSize, bSize)); | ||
| if (cmp == 0) { | ||
| return aSize < bSize; |
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.
use ? :
tests/test.cpp
Outdated
| TEST_EQ_STR(a[1]->c_str(), "two"); | ||
| TEST_EQ_STR(a[2]->c_str(), "one"); | ||
| TEST_EQ_STR(a[3]->c_str(), "onetwo"); | ||
| TEST_EQ(a[4]->str(), (std::string(charsB, sizeof(charsB)))); |
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.
why are both sides converted to 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.
This is to make sure that we compare the embedded null and what follows.
|
|
|
All comments addressed, commit amended. |
|
Thanks! |
#5058