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

Remove slice! from fixed_protocol #1207

Merged
merged 2 commits into from
Apr 29, 2024
Merged

Remove slice! from fixed_protocol #1207

merged 2 commits into from
Apr 29, 2024

Conversation

jmthomas
Copy link
Member

No description provided.

@jmthomas jmthomas requested a review from ryanmelt April 17, 2024 03:20
# and 1000x slower at large packets (1Mb)
# Run test/benchmarks/string_mod_benchmark.rb for details
packet_data = @data[0...identified_packet.defined_length + @discard_leading_bytes]
@data = @data[(identified_packet.defined_length + @discard_leading_bytes)..-1]
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is equivalent functionality. I tried to add a new test case to the spec but not sure if I fully covered the case because if you change ..-1 to ..-2 it still passes

# But slice! is 6x slower at small packets (1024)
# and 1000x slower at large packets (1Mb)
# Run test/benchmarks/string_mod_benchmark.rb for details
packet_data = @data[0...identified_packet.defined_length + @discard_leading_bytes]
Copy link
Member

Choose a reason for hiding this comment

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

Is this intentionally ... and shouldn't there be parens around the + expression?

Copy link
Member Author

Choose a reason for hiding this comment

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

Order of operations applies plus before range but it's clearer with parens

Copy link

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@jmthomas jmthomas merged commit 8f913bc into main Apr 29, 2024
16 of 17 checks passed
@jmthomas jmthomas deleted the fixed_performance branch April 29, 2024 15:24
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