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(ansi): truncate: truncate string when input length is equal to output #115

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

aymanbagabas
Copy link
Member

@aymanbagabas aymanbagabas commented Jul 8, 2024

goos: darwin
goarch: arm64
pkg: github.com/charmbracelet/x/ansi
                  │   old.txt   │              new.txt               │
                  │   sec/op    │   sec/op     vs base               │
TruncateString-16   24.96n ± 1%   25.83n ± 2%  +3.49% (p=0.001 n=10)

                  │  old.txt   │            new.txt             │
                  │    B/op    │    B/op     vs base            │
TruncateString-16   65.00 ± 0%   65.00 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

                  │  old.txt   │            new.txt             │
                  │ allocs/op  │ allocs/op   vs base            │
TruncateString-16   1.000 ± 0%   1.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

Fixes: charmbracelet/lipgloss#324
Fixes: #106

CC/ @mikelorant @jbcpollak

ansi/truncate.go Outdated Show resolved Hide resolved
@aymanbagabas
Copy link
Member Author

k, was able to get nearly the same performance by improving the implementation of StringWidth

@aymanbagabas aymanbagabas merged commit 9d42857 into main Jul 9, 2024
7 checks passed
@aymanbagabas aymanbagabas deleted the truncate-equal branch July 9, 2024 13:48
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.

Bug: Truncation in Table Cells
3 participants