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

chore: remove unneeded string cloning for arithmetic eval #324

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

reubeno
Copy link
Owner

@reubeno reubeno commented Jan 13, 2025

When we have a string that needs to be interpreted as an unexpanded arithmetic expression, there's no reason to wrap it in a struct that insists on an owned copy; we can directly pass through the &str to the core logic that's performing expansion and evaluation.

@reubeno reubeno requested a review from Copilot January 13, 2025 16:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

brush-core/src/arithmetic.rs:89

  • The expr variable is not defined within the expand_and_eval function. It should be replaced with expanded_self to correctly evaluate the expanded expression.
expr.eval(shell)

brush-core/src/arithmetic.rs Show resolved Hide resolved
Copy link

github-actions bot commented Jan 13, 2025

Test Results

    2 files      9 suites   1m 24s ⏱️
  587 tests   587 ✅ 0 💤 0 ❌
1 160 runs  1 160 ✅ 0 💤 0 ❌

Results for commit 32128bb.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jan 13, 2025

Performance Benchmark Report

Benchmark name Baseline (μs) Test/PR (μs) Delta (μs) Delta %
clone_shell_object 16.46 μs 16.45 μs -0.01 μs ⚪ Unchanged
eval_arithmetic 0.19 μs 0.18 μs -0.01 μs ⚪ Unchanged
expand_one_string 1.60 μs 1.64 μs 0.04 μs ⚪ Unchanged
for_loop 34.10 μs 32.56 μs -1.54 μs 🟢 -4.52%
function_call 3.50 μs 3.28 μs -0.21 μs ⚪ Unchanged
instantiate_shell 47.98 μs 47.50 μs -0.48 μs ⚪ Unchanged
instantiate_shell_with_init_scripts 22678.80 μs 21941.94 μs -736.86 μs 🟢 -3.25%
parse_bash_completion 1663.53 μs 1666.17 μs 2.65 μs ⚪ Unchanged
parse_sample_script 1.74 μs 1.80 μs 0.06 μs 🟠 +3.50%
run_echo_builtin_command 16.57 μs 15.88 μs -0.70 μs ⚪ Unchanged
run_one_external_command 2077.24 μs 2092.53 μs 15.28 μs ⚪ Unchanged
tokenize_sample_script 2.89 μs 2.77 μs -0.13 μs 🟢 -4.36%

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
brush-core/src/arithmetic.rs 🟢 98.4% 🟢 98.46% 🟢 0.06%
brush-core/src/extendedtests.rs 🟠 70.91% 🟠 67.35% 🔴 -3.56%
brush-core/src/interp.rs 🟢 90.76% 🟢 90.75% 🔴 -0.01%
brush-core/src/shell.rs 🟢 82.4% 🟢 82.27% 🔴 -0.13%
Overall Coverage 🟢 76.96% 🟢 76.91% 🔴 -0.05%

Minimum allowed coverage is 70%, this run produced 76.91%

@reubeno reubeno changed the title chore: remove unneeded clones for arith eval chore: remove unneeded string cloning for arithmetic eval Jan 13, 2025
@reubeno reubeno marked this pull request as ready for review January 13, 2025 17:04
@reubeno reubeno merged commit 437cd85 into main Jan 13, 2025
17 checks passed
@reubeno reubeno deleted the unneeded-clones branch January 13, 2025 17:06
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.

1 participant