From cc5b91a0e92db31ebfb54c72349542590c0ba180 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 30 Mar 2026 12:56:20 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20[performance=20improvement]?= =?UTF-8?q?=20optimize=20string=20length=20summation=20in=20config=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- src/codeweaver/providers/config/types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/codeweaver/providers/config/types.py b/src/codeweaver/providers/config/types.py index e9dabe9c1..6b5adbbd1 100644 --- a/src/codeweaver/providers/config/types.py +++ b/src/codeweaver/providers/config/types.py @@ -134,7 +134,8 @@ class DocumentRepr: async def serialize_for_upsert(self, texts: list[str]) -> list[Document]: """Serialize the document representations for Qdrant upsert.""" await asyncio.sleep(ZERO) - avg_length = int(sum(len(text.strip()) for text in texts) / len(texts)) if texts else 0 + # Optimization: sum(map(len, map(str.strip, texts))) is significantly faster than a generator comprehension + avg_length = int(sum(map(len, map(str.strip, texts))) / len(texts)) if texts else 0 options = await self.options.serialize_for_upsert(avg_length) return [Document(text=text, model=self.model, options=options) for text in texts]