Skip to content

Commit 1a4a2d4

Browse files
Merge pull request #9 from fabriziosalmi/codeflash/optimize-validate_regex-m6xkx22f
⚡️ Speed up function `validate_regex` by 9,172%
2 parents 1a98411 + a3104b2 commit 1a4a2d4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

json2haproxy.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
from pathlib import Path
66
from typing import List, Dict, Optional
7+
from functools import lru_cache
78

89
# Configure logging
910
logging.basicConfig(
@@ -46,6 +47,7 @@ def load_owasp_rules(file_path: Path) -> List[Dict]:
4647
logging.error(f"[!] Error loading OWASP rules: {e}")
4748
raise
4849

50+
@lru_cache(maxsize=None)
4951
def validate_regex(pattern: str) -> bool:
5052
"""
5153
Validate regex pattern for HAProxy.

0 commit comments

Comments
 (0)