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

fix(toggle): use -1 as index for toKey() with toggled item #167

Merged
merged 2 commits into from
Aug 14, 2024

Conversation

Minhir
Copy link
Member

@Minhir Minhir commented Aug 13, 2024

Summary

It's strange to call toKey for an item with different indexes. We can provide -1 instead and call it only once.

Related issue, if any:

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed
  • Related benchmarks have been added or updated, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size Difference (%)
M src/array/toggle.ts 257 1 +22 (+9%)

Footnotes

  1. Function size includes the import dependencies of the function.

@Minhir Minhir requested a review from aleclarson as a code owner August 13, 2024 18:39
@Minhir Minhir changed the title Call toggle toKey with -1 for an item fix(toggle): call toKey with -1 for an item Aug 13, 2024
@radashi-org radashi-org deleted a comment from radashi-bot Aug 14, 2024
@radashi-bot
Copy link

radashi-bot commented Aug 14, 2024

Benchmark Results

Name Current Baseline Change
toggle ▶︎ with item that does not exist 3,444,063.7 ops/sec ±0.79% 3,853,799.84 ops/sec ±0.68% 🔗 🐢 -10.63%
toggle ▶︎ with item that does exist 3,074,539.65 ops/sec ±0.26% 3,784,823.03 ops/sec ±0.23% 🔗 🐢 -18.77%
toggle ▶︎ with item that does exist and custom matcher 3,134,063.15 ops/sec ±0.57% 2,915,861.43 ops/sec ±3.31% 🔗 🚀 +7.48%
toggle ▶︎ with item that does not exist and custom matcher 2,929,082.75 ops/sec ±1.19% 3,177,778.3 ops/sec ±3.2% 🔗 🐢 -7.83%
toggle ▶︎ with strategy prepend 3,705,687.33 ops/sec ±0.2% 3,927,617.13 ops/sec ±0.18% 🔗 🐢 -5.65%

Generally speaking, any regression ≥20% should be investigated if it wasn't to be expected.

@aleclarson aleclarson force-pushed the update-toggle branch 2 times, most recently from bfb29ac to 0d4969c Compare August 14, 2024 22:22
@aleclarson aleclarson changed the title fix(toggle): call toKey with -1 for an item fix(toggle): use -1 as index for toKey() with toggled item Aug 14, 2024
@aleclarson aleclarson merged commit 10ee12d into radashi-org:main Aug 14, 2024
8 checks passed
@Minhir Minhir deleted the update-toggle branch August 15, 2024 07:33
Copy link

A new beta version 12.2.0-beta.6b76988 has been published to NPM. 🚀

To install:

The radashi@beta tag also includes this PR.

See the changes

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.

3 participants