From 4943e3a396f8ec8a524c59c600adc66b3acc0473 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 12:04:44 +0000 Subject: [PATCH] gen-libllama-abi: compile sort-key regex once outside the lambda Agent-Logs-Url: https://github.com/ggml-org/llama.cpp/sessions/cd21903e-afd2-477a-8285-0a2d46e1398c Co-authored-by: ggerganov <1991296+ggerganov@users.noreply.github.com> --- scripts/gen-libllama-abi.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/gen-libllama-abi.py b/scripts/gen-libllama-abi.py index 107864ac9b..3f0ad3f579 100644 --- a/scripts/gen-libllama-abi.py +++ b/scripts/gen-libllama-abi.py @@ -152,7 +152,13 @@ def extract_signatures(header_text: str) -> list[str]: if sig and '(' in sig: sigs.append(sig) - sigs.sort(key=lambda s: re.search(r'\b(llama_\w+)\s*\(', s).group(1) if re.search(r'\b(llama_\w+)\s*\(', s) else s) + _name_re = re.compile(r'\b(llama_\w+)\s*\(') + + def _sort_key(s: str) -> str: + m = _name_re.search(s) + return m.group(1) if m else s + + sigs.sort(key=_sort_key) return sigs