Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf14f27d

Browse files
author
Neil Conway
committed
Tweak: use memcpy() in text_time(), rather than manually copying bytes
in a loop.
1 parent85df43f commitf14f27d

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

‎src/backend/utils/adt/date.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.129 2007/02/27 23:48:07 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.130 2007/05/30 19:38:05 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1635,7 +1635,7 @@ time_text(PG_FUNCTION_ARGS)
16351635
result=palloc(len);
16361636

16371637
SET_VARSIZE(result,len);
1638-
memcpy(VARDATA(result),str,(len-VARHDRSZ));
1638+
memcpy(VARDATA(result),str,len-VARHDRSZ);
16391639

16401640
pfree(str);
16411641

@@ -1651,23 +1651,19 @@ time_text(PG_FUNCTION_ARGS)
16511651
Datum
16521652
text_time(PG_FUNCTION_ARGS)
16531653
{
1654-
text*str=PG_GETARG_TEXT_P(0);
1655-
inti;
1656-
char*sp,
1657-
*dp,
1658-
dstr[MAXDATELEN+1];
1654+
text*str=PG_GETARG_TEXT_P(0);
1655+
chardstr[MAXDATELEN+1];
1656+
size_tlen;
16591657

16601658
if (VARSIZE(str)-VARHDRSZ>MAXDATELEN)
16611659
ereport(ERROR,
16621660
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
16631661
errmsg("invalid input syntax for type time: \"%s\"",
16641662
VARDATA(str))));
16651663

1666-
sp=VARDATA(str);
1667-
dp=dstr;
1668-
for (i=0;i< (VARSIZE(str)-VARHDRSZ);i++)
1669-
*dp++=*sp++;
1670-
*dp='\0';
1664+
len=VARSIZE(str)-VARHDRSZ;
1665+
memcpy(dstr,VARDATA(str),len);
1666+
dstr[len]='\0';
16711667

16721668
returnDirectFunctionCall3(time_in,
16731669
CStringGetDatum(dstr),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp