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

Commit6d842be

Browse files
committed
Provide fast path in snprintf.c for conversion specs that are just "%s".
This case occurs often enough (around 45% of conversion specs executedin our regression tests are just "%s") that it's worth an extra testper conversion spec to allow skipping all the logic associated withfield widths and padding when it happens.Discussion:https://postgr.es/m/26193.1538582367@sss.pgh.pa.us
1 parentabd9ca3 commit6d842be

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎src/port/snprintf.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,19 @@ dopr(PrintfTarget *target, const char *format, va_list args)
431431

432432
/* Process conversion spec starting at *format */
433433
format++;
434+
435+
/* Fast path for conversion spec that is exactly %s */
436+
if (*format=='s')
437+
{
438+
format++;
439+
strvalue=va_arg(args,char*);
440+
Assert(strvalue!=NULL);
441+
dostr(strvalue,strlen(strvalue),target);
442+
if (target->failed)
443+
break;
444+
continue;
445+
}
446+
434447
fieldwidth=precision=zpad=leftjust=forcesign=0;
435448
longflag=longlongflag=pointflag=0;
436449
fmtpos=accum=0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp