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

Introduce String.replaceAll instance function #2814

Merged
merged 4 commits into from
Oct 16, 2023

Conversation

darkdrag00nv2
Copy link
Contributor

@darkdrag00nv2 darkdrag00nv2 commented Sep 24, 2023

Work towards #2813

Description

Adds str.replaceAll(_ of: String, _ with: String): String function to Cadence.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov
Copy link

codecov bot commented Sep 24, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (fa75807) 79.84% compared to head (57d4ad8) 79.84%.

Additional details and impacted files
@@                   Coverage Diff                   @@
##           feature/stable-cadence    #2814   +/-   ##
=======================================================
  Coverage                   79.84%   79.84%           
=======================================================
  Files                         343      343           
  Lines                       81056    81088   +32     
=======================================================
+ Hits                        64719    64747   +28     
- Misses                      14027    14029    +2     
- Partials                     2310     2312    +2     
Flag Coverage Δ
unittests 79.84% <87.50%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
runtime/sema/string_type.go 96.61% <100.00%> (+0.18%) ⬆️
runtime/interpreter/value.go 67.18% <84.61%> (+0.03%) ⬆️

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

runtime/sema/string_type.go Outdated Show resolved Hide resolved
runtime/interpreter/value.go Show resolved Hide resolved
@darkdrag00nv2
Copy link
Contributor Author

darkdrag00nv2 commented Sep 26, 2023

Force push to resolve merge conflict.

runtime/sema/string_type.go Outdated Show resolved Hide resolved
@darkdrag00nv2
Copy link
Contributor Author

@turbolent @dsainati1 Could you please take a look? Thanks!

@darkdrag00nv2
Copy link
Contributor Author

@SupunS Should we merge this? Seems a relatively straightforward change.

@SupunS SupunS merged commit 6dc6b38 into onflow:feature/stable-cadence Oct 16, 2023
8 of 11 checks passed
@darkdrag00nv2 darkdrag00nv2 deleted the string_replace branch October 16, 2023 20:32
@turbolent
Copy link
Member

turbolent commented Oct 18, 2023

Sorry I missed this! The PR looks good, but the function needs to have its computation metered, as it performs a non-constant operation. The same also applies to the other stdlib PRs that got opened so far.

This might require "inlining" the replaceAll call to the Go stdlib, and calling ReportComputation with a new (?) common.ComputationKind

I opened #2879 to track this, see the details there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants