rust-term-grid icon indicating copy to clipboard operation
rust-term-grid copied to clipboard

Performance issue with the redundancy operations

Open yyzdtccjdtc opened this issue 3 years ago • 1 comments

https://github.com/ogham/rust-term-grid/blob/1cbc10f4fd641e49c20e72afbad3f850af51ab61/src/lib.rs#L319

For this line of code, it will always update the value of widths[index], even if the value of it does not change. This introduces some redundant operations.

If we change the code to this, we can eliminate these redundant operations.

if widths[index] < cell.width{
     widths[index] = cell.width;
}

According to my tests, the average execution time decreased from 6.5s to 4.8s, which is a 1.37x speedup.

Hope this information helps!

yyzdtccjdtc avatar May 30 '22 05:05 yyzdtccjdtc

@ogham Is this repo still maintained?

pengfei-su avatar Mar 30 '23 22:03 pengfei-su