Skip to content

Commit 657bd31

Browse files
committed
Trivial optimization
- Not call `strlen` at the end of the zone name. - Use the initialized UTC string.
1 parent 64eba7a commit 657bd31

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

time.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -942,12 +942,14 @@ zone_str(const char *zone)
942942
return rb_fstring_lit("(NO-TIMEZONE-ABBREVIATION)");
943943
}
944944

945-
for (p = zone; *p; p++)
945+
for (p = zone; *p; p++) {
946946
if (!ISASCII(*p)) {
947947
ascii_only = 0;
948+
p += strlen(p);
948949
break;
949950
}
950-
len = p - zone + strlen(p);
951+
}
952+
len = p - zone;
951953
if (ascii_only) {
952954
str = rb_usascii_str_new(zone, len);
953955
}
@@ -1442,7 +1444,7 @@ guess_local_offset(struct vtm *vtm_utc, int *isdst_ret, VALUE *zone_ret)
14421444
if (lt(vtm_utc->year, INT2FIX(1916))) {
14431445
VALUE off = INT2FIX(0);
14441446
int isdst = 0;
1445-
zone = rb_fstring_lit("UTC");
1447+
zone = str_utc;
14461448

14471449
# if defined(NEGATIVE_TIME_T)
14481450
# if SIZEOF_TIME_T <= 4

0 commit comments

Comments
 (0)