ruby-changes:43104
From: naruse <ko1@a...>
Date: Fri, 27 May 2016 01:51:54 +0900 (JST)
Subject: [ruby-changes:43104] naruse:r55178 (trunk): * symbol.c (is_identchar): use ISDIGIT instead of rb_enc_isalnum.
naruse 2016-05-27 01:51:49 +0900 (Fri, 27 May 2016) New Revision: 55178 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55178 Log: * symbol.c (is_identchar): use ISDIGIT instead of rb_enc_isalnum. Though rb_enc_isalnum is encoding aware function, its argument here is *m, which is a single byte. Therefore ISDIGIT is faster. * symbol.c (is_special_global_name): ditto. * symbol.c (rb_enc_symname_type): ditto. Modified files: trunk/ChangeLog trunk/symbol.c Index: ChangeLog =================================================================== --- ChangeLog (revision 55177) +++ ChangeLog (revision 55178) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri May 27 01:00:36 2016 NARUSE, Yui <naruse@r...> + + * symbol.c (is_identchar): use ISDIGIT instead of rb_enc_isalnum. + Though rb_enc_isalnum is encoding aware function, its argument here + is *m, which is a single byte. Therefore ISDIGIT is faster. + + * symbol.c (is_special_global_name): ditto. + + * symbol.c (rb_enc_symname_type): ditto. + Fri May 27 00:39:40 2016 Nobuyoshi Nakada <nobu@r...> * include/ruby/ruby.h (rb_scan_args): add nul padding here to Index: symbol.c =================================================================== --- symbol.c (revision 55177) +++ symbol.c (revision 55178) @@ -28,7 +28,7 @@ static ID register_static_symid_str(ID, https://github.com/ruby/ruby/blob/trunk/symbol.c#L28 #define REGISTER_SYMID(id, name) register_static_symid((id), (name), strlen(name), enc) #include "id.c" -#define is_identchar(p,e,enc) (rb_enc_isalnum((unsigned char)(*(p)),(enc)) || (*(p)) == '_' || !ISASCII(*(p))) +#define is_identchar(p,e,enc) (ISALNUM((unsigned char)*(p)) || (*(p)) == '_' || !ISASCII(*(p))) #define op_tbl_count numberof(op_tbl) STATIC_ASSERT(op_tbl_name_size, sizeof(op_tbl[0].name) == 3); @@ -177,11 +177,11 @@ is_special_global_name(const char *m, co https://github.com/ruby/ruby/blob/trunk/symbol.c#L177 } } else { - if (!rb_enc_isdigit(*m, enc)) return 0; + if (!ISDIGIT(*m)) return 0; do { if (!ISASCII(*m)) mb = 1; ++m; - } while (m < e && rb_enc_isdigit(*m, enc)); + } while (m < e && ISDIGIT(*m)); } return m == e ? mb + 1 : 0; } @@ -278,9 +278,9 @@ rb_enc_symname_type(const char *name, lo https://github.com/ruby/ruby/blob/trunk/symbol.c#L278 break; default: - type = rb_enc_isupper(*m, enc) ? ID_CONST : ID_LOCAL; + type = ISUPPER(*m) ? ID_CONST : ID_LOCAL; id: - if (m >= e || (*m != '_' && !rb_enc_isalpha(*m, enc) && ISASCII(*m))) { + if (m >= e || (*m != '_' && !ISALPHA(*m) && ISASCII(*m))) { if (len > 1 && *(e-1) == '=') { type = rb_enc_symname_type(name, len-1, enc, allowed_attrset); if (type != ID_ATTRSET) return ID_ATTRSET; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/