Skip to content

Commit a004288

Browse files
committed
Another pre-compiled RE for better perf
Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
1 parent c6e81e4 commit a004288

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sphinxlint/checkers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,12 @@ def check_block(block_lineno, block):
461461
yield from errors
462462

463463

464+
_DANGLING_HYPHEN_RE = re.compile(r".*[a-z]-$")
465+
464466
@checker(".rst", rst_only=True)
465467
def check_dangling_hyphen(file, lines, options):
466468
"""Check for lines ending in a hyphen."""
467469
for lno, line in enumerate(lines):
468470
stripped_line = line.rstrip("\n")
469-
if re.match(r".*[a-z]-$", stripped_line):
471+
if _DANGLING_HYPHEN_RE.match(stripped_line):
470472
yield lno + 1, f"Line ends with dangling hyphen"

0 commit comments

Comments
 (0)