sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

Avoid tokens copy

Open living180 opened this issue 3 years ago • 1 comments

Partial fix for #621:

In TokenList._token_matching() avoid quadratic behavior resulting from taking a slice of self.tokens during each invocation. Since we are working with indexes anyway, just generate the indexes using range() and use normal indexing to access the desired tokens instead of calling enumerate() with a slice from self.tokens.

living180 avatar May 19 '21 12:05 living180

Codecov Report

Merging #622 (b4fb5de) into master (23d2993) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #622   +/-   ##
=======================================
  Coverage   96.82%   96.82%           
=======================================
  Files          20       20           
  Lines        1514     1514           
=======================================
  Hits         1466     1466           
  Misses         48       48           
Impacted Files Coverage Δ
sqlparse/sql.py 97.60% <100.00%> (ø)

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 23d2993...b4fb5de. Read the comment docs.

codecov[bot] avatar May 19 '21 12:05 codecov[bot]

Nice refactoring, thank you!

andialbrecht avatar Aug 08 '22 08:08 andialbrecht