[前][次][番号順一覧][スレッド一覧]

ruby-changes:58651

From: Nobuyoshi <ko1@a...>
Date: Fri, 8 Nov 2019 23:00:56 +0900 (JST)
Subject: [ruby-changes:58651] 11e21f1982 (master): Make prefix static

https://git.ruby-lang.org/ruby.git/commit/?id=11e21f1982

From 11e21f1982cbe41860b3f6755505ce063b74fc33 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 8 Nov 2019 23:00:36 +0900
Subject: Make prefix static


diff --git a/compile.c b/compile.c
index 1f4031a..131f82a 100644
--- a/compile.c
+++ b/compile.c
@@ -6753,10 +6753,10 @@ static const char * https://github.com/ruby/ruby/blob/trunk/compile.c#L6753
 iseq_builtin_function_name(ID mid)
 {
     const char *name = rb_id2name(mid);
-    const char prefix[] = "__builtin_";
-    const size_t prefix_len = strlen(prefix);
+    static const char prefix[] = "__builtin_";
+    const size_t prefix_len = sizeof(prefix) - 1;
 
-    if (UNLIKELY(strncmp("__builtin_", name, prefix_len) == 0)) {
+    if (UNLIKELY(strncmp(prefix, name, prefix_len) == 0)) {
         return &name[prefix_len];
     }
     else {
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]