Skip to content
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

fix typo #2080

Merged
merged 1 commit into from Nov 6, 2023
Merged

fix typo #2080

merged 1 commit into from Nov 6, 2023

Conversation

void-mian
Copy link
Contributor

Some typos in comments.

@void-mian
Copy link
Contributor Author

BTW, Can't I rely on these api? I see it's marked as private.

@lemire
Copy link
Member

lemire commented Nov 6, 2023

Merging.

@lemire lemire merged commit 665cbba into simdjson:master Nov 6, 2023
40 checks passed
@lemire
Copy link
Member

lemire commented Nov 6, 2023

Can't I rely on these api? I see it's marked as private.

What is your use case? These functions are meant for internal use. I am not sure how a user of the library would ever need them...

@void-mian
Copy link
Contributor Author

I've created a helper function that returns simdjson_result as the result. But I ended up using optional instead, because I noticed the error code was unreliable.

@lemire
Copy link
Member

lemire commented Nov 7, 2023

The error code should not be unreliable. Can you give me an example with code?

@void-mian
Copy link
Contributor Author

Sorry for the misunderstanding. I mean it's unstable, the doc says the error code may be changed. And here a example:

simdjson::simdjson_result<int> count_key_recursively(simdjson::ondemand::value& value, const std::string_view& key) {
    simdjson::error_code ec;
    simdjson::ondemand::object temp;
    if (value.get_object().get(temp)) {
        return ec;
    }
    // iterate the json recursively...
}

Since I don't need the error code here, I replace it with std::optional to indicate whether a parser error has occurred.

@lemire
Copy link
Member

lemire commented Nov 8, 2023

In that code, ec is never initialized, right?

Do you mean to write…

if(error_code ec = value.get_object().get(temp); ec) {
  return ec;
}

@void-mian
Copy link
Contributor Author

Yes, forgot to assign the error code.

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.

None yet

2 participants