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

Use string_view instead of const string&. #1134

Merged
merged 1 commit into from
Oct 15, 2023

Conversation

angriman
Copy link
Member

@angriman angriman commented Oct 3, 2023

std::string_view is a non-owning read-only view of a string, and it helps to avoid unnecessary memory allocations [1]. I think we should start using it instead of const std::string&.

[1] https://www.modernescpp.com/index.php/c-17-avoid-copying-with-std-string-view/

@fabratu
Copy link
Member

fabratu commented Oct 6, 2023

That makes sense (especially for the substring methods you refactored) - I think we can merge this PR as is. Will insert the refactoring of the remaining code base to the project plan.

@angriman angriman merged commit 07d02ea into networkit:master Oct 15, 2023
25 checks passed
@angriman angriman deleted the use-string-view branch October 15, 2023 14:23
PetholzA pushed a commit to PetholzA/networkit that referenced this pull request Oct 23, 2023
Use string_view instead of const string&.
PetholzA pushed a commit to PetholzA/networkit that referenced this pull request Oct 23, 2023
Use string_view instead of const string&.
PetholzA pushed a commit to PetholzA/networkit that referenced this pull request Oct 23, 2023
Use string_view instead of const string&.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants