From ce44e4996e6632871c18cdd7a7fb641be8ef34ef Mon Sep 17 00:00:00 2001
From: Isaac Muse <faceless.shop@gmail.com>
Date: Wed, 15 Jul 2026 16:23:14 -0600
Subject: [PATCH] Merge commit from fork

---
 docs/src/markdown/about/changelog.md |  1 +
 soupsieve/css_parser.py              |  2 +-
 tests/test_performance.py            | 56 ++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 tests/test_performance.py

diff --git a/soupsieve/css_parser.py b/soupsieve/css_parser.py
index d4ebc444..fd647df9 100644
--- a/soupsieve/css_parser.py
+++ b/soupsieve/css_parser.py
@@ -120,7 +120,7 @@
 CSS_STRING_ESCAPES = fr'(?:\\(?:[a-f0-9]{{1,6}}{WS}?|[^\r\n\f]|$|{NEWLINE}))'
 # CSS Identifier
 IDENTIFIER = fr'''
-(?:(?:-?(?:[^\x00-\x2f\x30-\x40\x5B-\x5E\x60\x7B-\x9f]|{CSS_ESCAPES})+|--)
+(?:(?:--|-?(?:[^\x00-\x2f\x30-\x40\x5B-\x5E\x60\x7B-\x9f]|{CSS_ESCAPES}))
 (?:[^\x00-\x2c\x2e\x2f\x3A-\x40\x5B-\x5E\x60\x7B-\x9f]|{CSS_ESCAPES})*)
 '''
 # `nth` content
diff --git a/tests/test_performance.py b/tests/test_performance.py
new file mode 100644
index 00000000..0923b1ce
--- /dev/null
+++ b/tests/test_performance.py
@@ -0,0 +1,56 @@
+"""Test performance cases."""
+import unittest
+import sys
+import signal
+import time
+import soupsieve as sv
+from soupsieve.util import SelectorSyntaxError
+
+
+class Timeout(Exception):
+    """Timeout exception."""
+
+
+@unittest.skipUnless(not sys.platform.startswith('win'), "Unix/Linux test")
+class TestPerformance(unittest.TestCase):
+    """Test performance."""
+
+    def assert_performance(self, selector):
+        """Test performance of of specific cases."""
+
+        LIMIT = 5.0
+
+        signal.signal(signal.SIGALRM, lambda *_: (_ for _ in ()).throw(Timeout()))
+        signal.setitimer(signal.ITIMER_REAL, LIMIT)
+        dt = None
+        t = 0
+        try:
+            t = time.perf_counter()
+            sv.compile(selector)
+            dt = time.perf_counter() - t
+        except SelectorSyntaxError:
+            dt = time.perf_counter() - t
+        except Timeout:
+            pass
+        finally:
+            signal.setitimer(signal.ITIMER_REAL, 0)
+
+        hung = dt is None
+        success = not hung and dt < 1.0
+
+        if not success:
+            print('Selector:', selector)
+            print(f"{'> %.0f s (HANG)' % LIMIT if hung else '%.3f s' % dt}")
+
+        self.assertTrue(success)
+
+    def test_performance_caase(self):
+        """Test performance cases."""
+
+        for n in (1000, 2000, 4000, 8000):
+            self.assert_performance("[a=" + "a" * n)
+
+        for n in (2000, 4000, 8000, 16000):
+            self.assert_performance("a" * n + "!")
+
+        self.assert_performance("[a=" + "a" * 12000)
