-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix timelib_parse_zone() performance problem.
This makes "new DateTimeZone("Europe/London");" 170 times faster. This is a hotfix for derickr/timelib#99
- Loading branch information
Showing
2 changed files
with
6 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,8 @@ static const timelib_tz_lookup_table timelib_timezone_utc[] = { | |
{ "utc", 0, 0, "UTC" }, | ||
}; | ||
|
||
#define MAX_ABBR_LEN 5 /* the longest name in "timezonemap.h" and "fallbackmap.h" */ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dstogov
Author
Member
|
||
|
||
static timelib_relunit const timelib_relunit_lookup[] = { | ||
{ "ms", TIMELIB_MICROSEC, 1000 }, | ||
{ "msec", TIMELIB_MICROSEC, 1000 }, | ||
|
@@ -749,7 +751,7 @@ static timelib_long timelib_lookup_abbr(const char **ptr, int *dst, char **tz_ab | |
word = timelib_calloc(1, end - begin + 1); | ||
memcpy(word, begin, end - begin); | ||
|
||
if ((tp = abbr_search(word, -1, 0))) { | ||
if (end - begin < MAX_ABBR_LEN && (tp = abbr_search(word, -1, 0))) { | ||
value = tp->gmtoffset; | ||
*dst = tp->type; | ||
value -= tp->type * 3600; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@dstogov
ext/date/lib/parse_date.re
changed in 2bf451b , but this file remain unchanged, is that correct?