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

Commite94c1a5

Browse files
committed
Avoid unnecessary division in interval_cmp_value().
Splitting the time field into days and microseconds is prettyuseless when we're just going to recombine those values.It's unclear if anyone will notice the speedup in real-worldcases, but a cycle shaved is a cycle earned.Discussion:https://postgr.es/m/2629129.1632675713@sss.pgh.pa.us
1 parent7c1d8a2 commite94c1a5

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,20 +2352,17 @@ static inline INT128
23522352
interval_cmp_value(constInterval*interval)
23532353
{
23542354
INT128span;
2355-
int64dayfraction;
23562355
int64days;
23572356

23582357
/*
2359-
*Separate time field into days and dayfraction, then add the month and
2360-
*day fields tothedays part. We cannot overflowint64days here.
2358+
*Combine the month and day fields into an integral number of days.
2359+
*Becausetheinputs are int32,int64arithmetic suffices here.
23612360
*/
2362-
dayfraction=interval->time %USECS_PER_DAY;
2363-
days=interval->time /USECS_PER_DAY;
2364-
days+=interval->month*INT64CONST(30);
2361+
days=interval->month*INT64CONST(30);
23652362
days+=interval->day;
23662363

2367-
/* Widendayfraction to 128 bits */
2368-
span=int64_to_int128(dayfraction);
2364+
/* Widentime field to 128 bits */
2365+
span=int64_to_int128(interval->time);
23692366

23702367
/* Scale up days to microseconds, forming a 128-bit product */
23712368
int128_add_int64_mul_int64(&span,days,USECS_PER_DAY);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp