Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mhfrantz
Copy link
Contributor

@mhfrantz mhfrantz force-pushed the issue-5058 branch 4 times, most recently from f8e2fd7 to 9a0a286 Compare November 21, 2018 01:12
@mhfrantz
Copy link
Contributor Author

Let me know if you prefer using std::lexicographical_compare instead of the DIY StringLessThan.

Copy link
Collaborator

@aardappel aardappel left a 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!

// 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)
{
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

{
const auto cmp = memcmp(aData, bData, (std::min)(aSize, bSize));
if (cmp == 0) {
return aSize < bSize;
Copy link
Collaborator

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))));
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@aardappel
Copy link
Collaborator

std::lexicographical_compare seems to be at least C++17, so that would require conditional compilation anyway.. so probably not worth it.

@mhfrantz
Copy link
Contributor Author

All comments addressed, commit amended.

@aardappel
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants