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

refactor: add fast branch if the string is short enough to not be truncated #1333

Merged
merged 2 commits into from
Nov 24, 2023

Conversation

ClementTsang
Copy link
Owner

@ClementTsang ClementTsang commented Nov 24, 2023

Description

A description of the change, what it does, and why it was made. If relevant (such as any change that modifies the UI), please provide screenshots of the changes:

Another branch to skip slicing/iteration if the string is short enough compared to the width given that it must fit. This makes it fast to have a small string and/or a lot of space to accommodate it, which is likely the most usual case.

The faster_ascii below shows benchmark speed of each function (original is the implementation before #1330).

lines
lines
lines
lines

Issue

If applicable, what issue does this address?

Closes: #

Testing

If relevant, please state how this was tested. All changes must be tested to work:

If this is a code change, please also indicate which platforms were tested:

  • Windows
  • macOS
  • Linux

Checklist

If relevant, ensure the following have been met:

  • Areas your change affects have been linted using rustfmt (cargo fmt)
  • The change has been tested and doesn't appear to cause any unintended breakage
  • Documentation has been added/updated if needed (README.md, help menu, doc pages, etc.)
  • The pull request passes the provided CI pipeline
  • There are no merge conflicts
  • If relevant, new tests were added (don't worry too much about coverage)

Copy link

codecov bot commented Nov 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a93521d) 31.77% compared to head (d111d07) 31.77%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1333   +/-   ##
=======================================
  Coverage   31.77%   31.77%           
=======================================
  Files          97       97           
  Lines       16978    16978           
=======================================
  Hits         5395     5395           
  Misses      11583    11583           
Flag Coverage Δ
macos-12 33.55% <100.00%> (ø)
ubuntu-latest 33.35% <100.00%> (ø)
windows-2019 33.58% <100.00%> (ø)

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.

@ClementTsang ClementTsang merged commit 94e4573 into master Nov 24, 2023
33 checks passed
@ClementTsang ClementTsang deleted the truncate_str_full_fast_path branch November 24, 2023 08:13
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