-
Notifications
You must be signed in to change notification settings - Fork 8
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
string_view version of script::find_symbol_by_name
and few others
#30
Comments
Partial duplicate of #21, but a good point. Until I can figure out a C++17 compatible way of using string-views all the way down, this is probably a good solution; especially for case-insensitive strings. |
lmichaelis
added a commit
that referenced
this issue
Nov 6, 2022
Since we do a copy internally anyways, it doesn't hurt to allow users to pass a `std::string_view` instead of a `std::string` which might avoid unnecessary string copies. This change cascades to many other APIs related to the script and VM.
lmichaelis
added a commit
that referenced
this issue
Nov 6, 2022
This will reduce the number of small allocations needed for the underlying `std::unordered_map`. It also allows `way_net::waypoint` to take a `std::string_view` instead of a `const std::string&`
Since I've been able to implement most of these as |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current syntax:
symbol* script::find_symbol_by_name(const std::string& name)
forces client to bakestd::string
into interface.for find function this is especially unnecessary, since it does string copy immediatly after:
In general it's probably would be good to pass read-only strings as
string_view
in all cases. If implementation then uses this string as key to has-map or similar - solve this locally inside the function.Other places:
The text was updated successfully, but these errors were encountered: