a bit improvement of array_to_text

PostgreSQL has a function array_to_string(anyarray, text), which is the same of delimiter.join(array) in Python. But I found it is so slow relatively than the implementation of Perl and Python.

postgresql-8.2.5/src/backend/utils/adt/varlena.c, line 2749-2753, in function array_to_text shows

if (printed)
  appendStringInfo(&buf, "%s%s", fldsep, value);
else
  appendStringInfoString(&buf, value);
printed = true;

The variable `printed' means if the first value has been printed into StringInfo buffer. From second value on, the delimiter `fldsep' will be printed. The appendStringInfo() is a function that appends given string on buffer just like StringBuffer.append(String) in Java, except it accepts va_list arguments. I guess this is the neck.

if (printed)
  appendStringInfoString(&buf, fldsep);
appendStringInfoString(&buf, value);
printed = true;

Testing this code, the speed got up though just a little. I would like take benchmark...