| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIdeally this parameter should be an const ada::url&. It doesn't make sense to pass an ada::result in when we always expect it to be filled with the "valid" value.
In fact the call sites should probably change from this:
to
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityout.value() returns a copy. The current implementation looks unsafe, but CHECK(out) ensures that it is not. I tried to avoid returning a copy. @lemire wrote about this on Ada's discussion board: ada-url/ada#200
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think you misunderstood ada-url/ada#200. out.value() (and equivalently *out) does not return a copy by itself. It returns a reference, so if you put it into a const ada::url& then no copies are made.
On the other hand, ada::url url = *out, which would make a copy. That's not what I'm suggesting here.
Alternatively, you can also do
ada::result out = ada::parse(input.ToStringView()); CHECK(out); ada::url url = std::move(*out);which is written under the "performance tip". It would also avoid a copy.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt is likely that the current code is safe and efficient. I think we are discussing 'coding style' which is subjective.
I don't personally find the url->... annoying.
I am slightly triggered by the (*argv)[..] however. :-)
What about using a reference to an array instead?
(The ampersand would be dropped from the calling site.)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt's a style guide thing: pointers for things that are mutated, const references otherwise.
With mutable references it's sometimes ambiguous to a reader if code operates on the original or on a copy. With pointers, no such ambiguity exists.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.