Small improvement to json out functions by using cstring_to_text_with_len instead of cstring_to_text

Lists: pgsql-hackers
From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Small improvement to json out functions by using cstring_to_text_with_len instead of cstring_to_text
Date: 2013-11-14 07:18:03
Message-ID: CAApHDvoBeogDdc5g6FzyRkGOCJmtAa6vk3yg03CqcwCRbYErZw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Here's a small patch which should speedup json out functions a little bit
by removing a call to strlen for which could be a long string.
The length of the string is already known by the StringInfoData, so there's
no point in letting cstring_to_text() loop over the whole string again.

Regards

David Rowley

Attachment Content-Type Size
ctring_to_text_with_len.diff text/plain 2.0 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Small improvement to json out functions by using cstring_to_text_with_len instead of cstring_to_text
Date: 2013-11-18 15:26:55
Message-ID: CA+TgmoYFTbwKt=hbKhKf-j6=2TMJmqRJAYtV+=eo5+QzPOMcwQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Nov 14, 2013 at 2:18 AM, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> Hi,
>
> Here's a small patch which should speedup json out functions a little bit by
> removing a call to strlen for which could be a long string.
> The length of the string is already known by the StringInfoData, so there's
> no point in letting cstring_to_text() loop over the whole string again.

Committed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company