mirror of
https://github.com/postgres/postgres.git
synced 2025-05-09 18:21:05 +03:00
pq_getstring doesn't go through pq_getbyte anymore, for better performance.
This commit is contained in:
parent
32c6c99e0b
commit
eef5c4f0e5
@ -29,7 +29,7 @@
|
|||||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: pqcomm.c,v 1.130 2002/04/03 00:44:27 tgl Exp $
|
* $Id: pqcomm.c,v 1.131 2002/04/20 23:35:43 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -569,22 +569,39 @@ pq_getbytes(char *s, size_t len)
|
|||||||
int
|
int
|
||||||
pq_getstring(StringInfo s)
|
pq_getstring(StringInfo s)
|
||||||
{
|
{
|
||||||
int c;
|
int i;
|
||||||
|
|
||||||
/* Reset string to empty */
|
/* Reset string to empty */
|
||||||
s->len = 0;
|
s->len = 0;
|
||||||
s->data[0] = '\0';
|
s->data[0] = '\0';
|
||||||
|
|
||||||
/* Read until we get the terminating '\0' */
|
/* Read until we get the terminating '\0' */
|
||||||
while ((c = pq_getbyte()) != EOF && c != '\0')
|
for(;;)
|
||||||
appendStringInfoCharMacro(s, c);
|
{
|
||||||
|
while (PqRecvPointer >= PqRecvLength)
|
||||||
if (c == EOF)
|
{
|
||||||
return EOF;
|
if (pq_recvbuf()) /* If nothing in buffer, then recv some */
|
||||||
|
return EOF; /* Failed to recv data */
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = PqRecvPointer; i < PqRecvLength; i++)
|
||||||
|
if (PqRecvBuffer[i] == '\0')
|
||||||
|
{
|
||||||
|
/* does not copy the \0 */
|
||||||
|
appendBinaryStringInfo(s, PqRecvBuffer + PqRecvPointer,
|
||||||
|
i - PqRecvPointer);
|
||||||
|
PqRecvPointer += i + 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we're here we haven't got the \0 in the buffer yet. */
|
||||||
|
|
||||||
|
appendBinaryStringInfo(s, PqRecvBuffer + PqRecvPointer,
|
||||||
|
PqRecvLength - PqRecvPointer);
|
||||||
|
PqRecvPointer = PqRecvLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* --------------------------------
|
/* --------------------------------
|
||||||
* pq_putbytes - send bytes to connection (not flushed until pq_flush)
|
* pq_putbytes - send bytes to connection (not flushed until pq_flush)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user