Skip to content

improved string padded #440

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

Merged
merged 4 commits into from
Jan 10, 2020
Merged

improved string padded #440

merged 4 commits into from
Jan 10, 2020

Conversation

DBJDBJ
Copy link
Contributor

@DBJDBJ DBJDBJ commented Jan 9, 2020

take two ...

DBJDBJ added 4 commits January 8, 2020 00:17
std::string argument passed by const reference
ctor added with std::string_view  argument
`allocate_padded_buffer()`  moved here with **optional** check on `length < 1`
@DBJDBJ
Copy link
Contributor Author

DBJDBJ commented Jan 9, 2020

ps :)

  1. struct padded_string final { . . . }; final is opportunity for optimization. And it is indeed used for that. One can use godbolt to check.

  2. size_t length {} --- Why the empty parentheses? That is the value initialization ; value initialized object might be called as "zeroed". the object is given determinate value: zero, null, etc ...

    1. size_t length is the default initialization -- object is given an indeterminate value.

Example:

int my_array[10] {}; // all elements 0 in C++, not allowed in C

@lemire
Copy link
Member

lemire commented Jan 10, 2020

Merging.

@lemire lemire merged commit 85e84fc into simdjson:master Jan 10, 2020
@DBJDBJ DBJDBJ deleted the dbjdbj_string_padded branch January 11, 2020 13:03
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