Skip to content

Commit

Permalink
Limit cache key in cell_len to 512
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Mar 14, 2022
1 parent eed6cbf commit c4cf06d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Improve performance of cell_length https://github.com/Textualize/rich/pull/2061

## [12.0.1] - 2022-03-14

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion rich/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def cell_len(text: str, _cache: Dict[str, int] = LRUCache(1024 * 4)) -> int:

_get_size = get_character_cell_size
total_size = sum(_get_size(character) for character in text)
_cache[text] = total_size
if len(text) <= 512:
_cache[text] = total_size
return total_size


Expand Down

0 comments on commit c4cf06d

Please sign in to comment.