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

Add Cool.nomark in 6.e #5562

Merged
merged 1 commit into from May 15, 2024
Merged

Add Cool.nomark in 6.e #5562

merged 1 commit into from May 15, 2024

Conversation

lizmat
Copy link
Contributor

@lizmat lizmat commented May 7, 2024

As suggested in Raku/problem-solving#427

Notes on implementation:

  • Cool.nomark converts to string and delegates to Str.nomark
  • in Str.nomark: check if empty string, return invocant if so
  • decompose the string, return invocant if same number of elements (aka: no codepoint was decomposed)
  • check each codepoint, only add to buffer if not a mark
  • convert back to string and return

For strings with no marks, this is about 11x faster than using .samemark for a string of 20 characters. For a string with 20 characters with marks, this is about 1.5x as fast.

As suggested in Raku/problem-solving#427

Notes on implementation:
- Cool.nomark converts to string and delegates to Str.nomark
- in Str.nomark: check if empty string, return invocant if so
- decompose the string, return invocant if same number of elements
  (aka: no codepoint was decomposed)
- check each codepoint, only add to buffer if not a mark
- convert back to string and return

For strings with no marks, this is about 11x faster than using
.samemark for a string of 20 characters.  For a string with 20
characters with marks, this is about 1.5x as fast.
@lizmat lizmat merged commit 5eb1da8 into main May 15, 2024
5 of 11 checks passed
@lizmat lizmat deleted the lizmat-nomark branch May 15, 2024 12:55
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.

None yet

1 participant