lsd icon indicating copy to clipboard operation
lsd copied to clipboard

refactor(name): reduce unnecessary String allocation

Open TeamTamoad opened this issue 2 years ago • 4 comments

This PR improve performance of escape and hyperlink functions of Name struct by reducing number of String allocation.


TODO

  • [x] Use cargo fmt
  • [ ] Add necessary tests
  • [ ] Add changelog entry
  • [ ] Update default config/theme in README (if applicable)
  • [ ] Update man page at lsd/doc/lsd.md (if applicable)

TeamTamoad avatar Jun 17 '22 20:06 TeamTamoad

Codecov Report

Merging #676 (4622927) into master (2ffb59c) will increase coverage by 0.01%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #676      +/-   ##
==========================================
+ Coverage   88.32%   88.34%   +0.01%     
==========================================
  Files          41       41              
  Lines        4607     4606       -1     
==========================================
  Hits         4069     4069              
+ Misses        538      537       -1     
Impacted Files Coverage Δ
src/meta/name.rs 89.92% <100.00%> (+0.33%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2ffb59c...4622927. Read the comment docs.

codecov-commenter avatar Jun 17 '22 20:06 codecov-commenter

2022-06-18-10-34-07

Is it really making much of a difference? I was getting mostly mixed results with original version being better(within error margin).

I tried it even without --tree and pretty much similar results.

meain avatar Jun 18 '22 05:06 meain

Hmm. Maybe this changes doesn't significantly improve performance of the program. However, I'll try writing a benchmark to test performance render, escape and hyperlink functions of Name struct. What do you think about Cow<str>? Do you have any concern about its complexity?

TeamTamoad avatar Jun 19 '22 05:06 TeamTamoad

Do you have any concern about its complexity?

As long as it provides some perf improvement, I don't mind the added complexity.

meain avatar Jun 19 '22 05:06 meain

I'm closing this PR for now. We can revisit it later if you think this could improve things here.

meain avatar Aug 23 '22 16:08 meain