Skip to content

Conversation

@NathanBaulch
Copy link
Contributor

Chaining TrimLeft and TrimRight means the input collection will be unnecessarily "Keyified" twice.

Speaking of trim helpers, I was surprised to see that TrimPrefix trims all instances of the leading slice, not just the first. This is different from the stdlib strings.TrimPrefix and should probably be documented. Same with the suffix version.

@codecov
Copy link

codecov bot commented Sep 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.51%. Comparing base (850d795) to head (8ee1054).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #689      +/-   ##
==========================================
+ Coverage   94.49%   94.51%   +0.02%     
==========================================
  Files          18       18              
  Lines        3416     3430      +14     
==========================================
+ Hits         3228     3242      +14     
  Misses        174      174              
  Partials       14       14              
Flag Coverage Δ
unittests 94.51% <100.00%> (+0.02%) ⬆️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@NathanBaulch
Copy link
Contributor Author

NathanBaulch commented Sep 26, 2025

Actually, thinking about this more... Chaining DropWhile and DropRightWhile means allocating two slices which isn't ideal. This is now fixed.
Any helper that chains other helpers internally should take these kinds of costs into consideration.

@samber samber merged commit 1df48c4 into samber:master Sep 26, 2025
11 checks passed
@NathanBaulch NathanBaulch deleted the trimperf branch September 26, 2025 12:21
NathanBaulch added a commit to NathanBaulch/lo that referenced this pull request Sep 30, 2025
* perf: avoid Keyify twice in Trim

* pref: avoid two slice allocations in Trim
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