Skip to content

Commit 715ffb2

Browse files
committed
Revert "A more complex cache for hide_non_rst_blocks()"
This reverts commit 7d63ef3.
1 parent e3515d9 commit 715ffb2

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

sphinxlint/utils.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ def is_multiline_non_rst_block(line):
159159
return False
160160

161161

162-
_NON_RST_BLOCKS_CACHE = {}
163162
_ZERO_OR_MORE_SPACES_RE = re.compile(" *")
164163

165164

@@ -168,14 +167,7 @@ def hide_non_rst_blocks(lines, hidden_block_cb=None):
168167
169168
The filter actually replace "removed" lines by empty lines, so the
170169
line numbering still make sense.
171-
172-
This function is quite hot, so we cache the returned value where possible.
173-
The function is only "pure" when hidden_block_cb is None, however,
174-
so we can only safely cache the output when hidden_block_cb=None.
175170
"""
176-
lines = tuple(lines)
177-
if hidden_block_cb is None and lines in _NON_RST_BLOCKS_CACHE:
178-
return _NON_RST_BLOCKS_CACHE[lines]
179171
in_literal = None
180172
excluded_lines = []
181173
block_line_start = None
@@ -203,10 +195,7 @@ def hide_non_rst_blocks(lines, hidden_block_cb=None):
203195
output.append(line)
204196
if excluded_lines and hidden_block_cb:
205197
hidden_block_cb(block_line_start, "".join(excluded_lines))
206-
output = tuple(output)
207-
if hidden_block_cb is None:
208-
_NON_RST_BLOCKS_CACHE[lines] = output
209-
return output
198+
return tuple(output)
210199

211200

212201
_starts_with_directive_marker = re.compile(rf"\.\. {rst.ALL_DIRECTIVES}::").match

0 commit comments

Comments
 (0)