summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-02-16 18:54:08 +0900
committerNobuyoshi Nakada <[email protected]>2025-02-17 18:27:24 +0900
commit657bd31cc74578dfa6002193cf9b98b2b7861a65 (patch)
treea3ce6722c60c71c50916186a6344f15da90869f7 /time.c
parent64eba7a01a7741774e10cab153196149c2bff00f (diff)
Trivial optimization
- Not call `strlen` at the end of the zone name. - Use the initialized UTC string.
Diffstat (limited to 'time.c')
-rw-r--r--time.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/time.c b/time.c
index deb44096af..d19d1873f8 100644
--- a/time.c
+++ b/time.c
@@ -942,12 +942,14 @@ zone_str(const char *zone)
return rb_fstring_lit("(NO-TIMEZONE-ABBREVIATION)");
}
- for (p = zone; *p; p++)
+ for (p = zone; *p; p++) {
if (!ISASCII(*p)) {
ascii_only = 0;
+ p += strlen(p);
break;
}
- len = p - zone + strlen(p);
+ }
+ len = p - zone;
if (ascii_only) {
str = rb_usascii_str_new(zone, len);
}
@@ -1442,7 +1444,7 @@ guess_local_offset(struct vtm *vtm_utc, int *isdst_ret, VALUE *zone_ret)
if (lt(vtm_utc->year, INT2FIX(1916))) {
VALUE off = INT2FIX(0);
int isdst = 0;
- zone = rb_fstring_lit("UTC");
+ zone = str_utc;
# if defined(NEGATIVE_TIME_T)
# if SIZEOF_TIME_T <= 4