Re: [PATCH] avoid double scanning in function byteain
Kirill Reshke <reshkekirill@gmail.com>
From: Kirill Reshke <reshkekirill@gmail.com>
To: Steven Niu <niushiji@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-03-26T08:37:32Z
Lists: pgsql-hackers
On Wed, 26 Mar 2025 at 12:17, Steven Niu <niushiji@gmail.com> wrote: > > Hi, Hi! > This double scanning can be inefficient, especially for large inputs. > So I optimized the function to eliminate the need for two scans, > while preserving correctness and efficiency. While the argument that processing input once not twice is fast is generally true, may we have some simple bench here just to have an idea how valuable this patch is? Patch: >+ /* Handle traditional escaped style in a single pass */ >+ input_len = strlen(inputText); >+ result = palloc(input_len + VARHDRSZ); /* Allocate max possible size */ > rp = VARDATA(result); >+ tp = inputText; >+ > while (*tp != '\0') Isn't this `strlen` O(n) + `while` O(n)? Where is the speed up? [0] https://github.com/bminor/glibc/blob/master/string/strlen.c#L43-L45 -- Best regards, Kirill Reshke
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Speed up byteain by not parsing traditional-style input twice.
- 3683af617044 19 (unreleased) landed