Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2ba4826

Browse files
committed
Suppress useless memmove() when buffer already contains left-justified
data.
1 parent 3fdfce6 commit 2ba4826

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/interfaces/libpq/fe-misc.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
*
2727
* IDENTIFICATION
28-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.48 2001/03/31 23:13:30 tgl Exp $
28+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.49 2001/05/28 15:29:51 tgl Exp $
2929
*
3030
*-------------------------------------------------------------------------
3131
*/
@@ -400,14 +400,20 @@ pqReadData(PGconn *conn)
400400
/* Left-justify any data in the buffer to make room */
401401
if (conn->inStart < conn->inEnd)
402402
{
403-
memmove(conn->inBuffer, conn->inBuffer + conn->inStart,
404-
conn->inEnd - conn->inStart);
405-
conn->inEnd -= conn->inStart;
406-
conn->inCursor -= conn->inStart;
407-
conn->inStart = 0;
403+
if (conn->inStart > 0)
404+
{
405+
memmove(conn->inBuffer, conn->inBuffer + conn->inStart,
406+
conn->inEnd - conn->inStart);
407+
conn->inEnd -= conn->inStart;
408+
conn->inCursor -= conn->inStart;
409+
conn->inStart = 0;
410+
}
408411
}
409412
else
413+
{
414+
/* buffer is logically empty, reset it */
410415
conn->inStart = conn->inCursor = conn->inEnd = 0;
416+
}
411417

412418
/*
413419
* If the buffer is fairly full, enlarge it. We need to be able to

0 commit comments

Comments
 (0)