Skip to content

Introduce reverse in Fixed/Variable sized Array type#2654

Merged
SupunS merged 8 commits into
onflow:masterfrom
darkdrag00nv2:reversed_array
Jul 19, 2023
Merged

Introduce reverse in Fixed/Variable sized Array type#2654
SupunS merged 8 commits into
onflow:masterfrom
darkdrag00nv2:reversed_array

Conversation

@darkdrag00nv2

@darkdrag00nv2 darkdrag00nv2 commented Jul 11, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

codecov Bot commented Jul 11, 2023

Copy link
Copy Markdown

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
Copy Markdown
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
Comment thread runtime/tests/interpreter/interpreter_test.go Outdated
Comment thread runtime/interpreter/value.go Outdated
Comment thread runtime/tests/interpreter/interpreter_test.go Outdated

@SupunS SupunS left a comment

Copy link
Copy Markdown
Member

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

Comment thread runtime/sema/type.go Outdated
Comment thread runtime/interpreter/value.go Outdated
Comment thread runtime/tests/checker/arrays_dictionaries_test.go Outdated
darkdrag00nv2 and others added 3 commits July 19, 2023 19:49
Co-authored-by: Supun Setunga <supun.setunga@gmail.com>
Co-authored-by: Supun Setunga <supun.setunga@gmail.com>
@SupunS SupunS merged commit 24ca444 into onflow:master Jul 19, 2023
@darkdrag00nv2 darkdrag00nv2 deleted the reversed_array branch July 19, 2023 16:12

@turbolent turbolent left a comment

Copy link
Copy Markdown
Member

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