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 reverse in Fixed/Variable sized Array type #2654

Merged
merged 8 commits into from
Jul 19, 2023

Conversation

darkdrag00nv2
Copy link
Contributor

@darkdrag00nv2 darkdrag00nv2 commented Jul 11, 2023

Work towards #2605

Description

Introduce reverse function for creating a copy of a Variable/Fixed size Array value with its entries reversed.

This function would be unavailable to resource arrays since resources cannot be copied.

Will send docs PR post the merge.


  • 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

@dsainati1
Copy link
Contributor

Nit: I'm not sold on the naming here. How about having this reverse-and-copy function be called reverse, and then change the mutating one here #2626 to be reverseInPlace or something similar?

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #2654 (4d42e5f) into master (316e8a9) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2654      +/-   ##
==========================================
+ Coverage   78.53%   78.57%   +0.03%     
==========================================
  Files         338      338              
  Lines       78143    78217      +74     
==========================================
+ Hits        61373    61457      +84     
+ Misses      14483    14474       -9     
+ Partials     2287     2286       -1     
Flag Coverage Δ
unittests 78.57% <100.00%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
runtime/interpreter/location.go 100.00% <100.00%> (ø)
runtime/interpreter/value.go 68.96% <100.00%> (+0.10%) ⬆️
runtime/script_executor.go 91.89% <100.00%> (ø)
runtime/sema/type.go 89.64% <100.00%> (+0.06%) ⬆️

... and 1 file with indirect coverage changes

@darkdrag00nv2
Copy link
Contributor Author

@dsainati1 I was trying to follow the Swift convention but your suggestion does sound clearer. Will update this and the other PR accordingly.

@darkdrag00nv2 darkdrag00nv2 changed the title Introduce reversed in Fixed/Variable sized Array type Introduce reverse in Fixed/Variable sized Array type Jul 11, 2023
runtime/tests/interpreter/interpreter_test.go Outdated Show resolved Hide resolved
runtime/interpreter/value.go Outdated Show resolved Hide resolved
runtime/tests/interpreter/interpreter_test.go Outdated Show resolved Hide resolved
Copy link
Member

@SupunS SupunS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just some minor suggestions

runtime/sema/type.go Outdated Show resolved Hide resolved
runtime/interpreter/value.go Outdated Show resolved Hide resolved
runtime/tests/checker/arrays_dictionaries_test.go Outdated Show resolved Hide resolved
@SupunS SupunS merged commit 24ca444 into onflow:master Jul 19, 2023
@darkdrag00nv2 darkdrag00nv2 deleted the reversed_array branch July 19, 2023 16:12
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

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