Skip to content

use std::string_view for safe_string2int#9009

Merged
kroening merged 2 commits into
developfrom
safe_string2int
May 27, 2026
Merged

use std::string_view for safe_string2int#9009
kroening merged 2 commits into
developfrom
safe_string2int

Conversation

@kroening
Copy link
Copy Markdown
Collaborator

The variants of safe_string2int now accept an std::string_view, instead of an std::string, in the hope of avoiding copies.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.56%. Comparing base (258b08c) to head (8af8647).

Files with missing lines Patch % Lines
src/goto-instrument/skip_loops.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #9009   +/-   ##
========================================
  Coverage    80.56%   80.56%           
========================================
  Files         1707     1707           
  Lines       189118   189134   +16     
  Branches        73       73           
========================================
+ Hits        152363   152385   +22     
+ Misses       36755    36749    -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

kroening and others added 2 commits May 26, 2026 15:09
The variants of safe_string2int now accept an std::string_view, instead of
an std::string, in the hope of avoiding copies.

Pass std::string_view by value (not const-reference) in all safe
and optional variants, following C++ Core Guidelines F.16 and
standard library convention.
Now that safe_string2unsigned and safe_string2size_t accept
std::string_view, call sites that previously allocated a temporary
std::string via std::string::substr() can use the non-allocating
std::string_view::substr() instead. Convert three such sites:

- src/memory-analyzer/analyze_symbol.cpp (two occurrences):
  address_string.substr(2) allocated; string_view{...}.substr(2)
  returns a view into the existing string.

- src/goto-instrument/skip_loops.cpp:
  val.substr(delim+1) allocated; string_view{val}.substr(delim+1)
  avoids the copy.

- src/goto-analyzer/taint_parser.cpp:
  std::string(where, 9, npos) allocated; string_view{where}.substr(9)
  avoids the copy.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@kroening kroening merged commit 4a1cc53 into develop May 27, 2026
44 checks passed
@kroening kroening deleted the safe_string2int branch May 27, 2026 00:21
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