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

Appearance settings

Commit 6d842be

Browse filesBrowse 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 executed in our regression tests are just "%s") that it's worth an extra test per conversion spec to allow skipping all the logic associated with field widths and padding when it happens. Discussion: https://postgr.es/m/26193.1538582367@sss.pgh.pa.us
1 parent abd9ca3 commit 6d842be
Copy full SHA for 6d842be

File tree

Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed
Open diff view settings
Collapse file

‎src/port/snprintf.c‎

Copy file name to clipboardExpand all lines: src/port/snprintf.c
+13Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.