From: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
---|---|
To: | Steven Niu <niushiji(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: [PATCH] avoid double scanning in function byteain |
Date: | 2025-03-26 08:37:32 |
Message-ID: | CALdSSPiov_2HrvLxHEUYD=LpJ6oetQ_-9=D77+j2Spi3TEgepw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 26 Mar 2025 at 12:17, Steven Niu <niushiji(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | vignesh C | 2025-03-26 08:53:55 | Re: Windows: openssl & gssapi dislike each other |
Previous Message | vignesh C | 2025-03-26 08:18:28 | Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows |