diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-07 07:48:24 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-07 07:48:24 +0000 |
commit | fa335a332386d2a57d32f8577035b18fd2a096a0 (patch) | |
tree | e349db2deba76d2997915dae73b15054c3c7dfb5 /encoding.c | |
parent | 5d2465461d7f0fdccaa8624cff75f674afe2055b (diff) | |
download | ruby-fa335a332386d2a57d32f8577035b18fd2a096a0.tar.gz ruby-fa335a332386d2a57d32f8577035b18fd2a096a0.tar.xz ruby-fa335a332386d2a57d32f8577035b18fd2a096a0.zip |
* include/ruby/oniguruma.h (OnigEncodingType): new member
ruby_encoding_index to avoid linear search in rb_enc_to_index.
* include/ruby/encoding.h (rb_enc_to_index): macro defined to use
ruby_encoding_index.
* encoding.c (rb_enc_to_index): removed.
(enc_register_at): initialize ruby_encoding_index member.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/encoding.c b/encoding.c index 65609763a..fc7fa37e2 100644 --- a/encoding.c +++ b/encoding.c @@ -67,7 +67,7 @@ enc_check_encoding(VALUE obj) RDATA(obj)->dmark != enc_mark) { return -1; } - index = rb_enc_to_index(RDATA(obj)->data); + index = rb_enc_to_index((rb_encoding*)RDATA(obj)->data); if (rb_enc_from_index(index) != RDATA(obj)->data) return -1; return index; @@ -141,6 +141,7 @@ enc_register_at(int index, const char *name, rb_encoding *encoding) *ent->enc = *encoding; encoding = ent->enc; encoding->name = name; + encoding->ruby_encoding_index = index; if (rb_cEncoding) { /* initialize encoding data */ enc_new(encoding); @@ -474,20 +475,6 @@ rb_enc_associate_index(VALUE obj, int idx) rb_enc_internal_set_index(obj, idx); } -int -rb_enc_to_index(rb_encoding *enc) -{ - int i; - - if (!enc) return 0; - for (i=0; i<enc_table_size; i++) { - if (enc_table[i].enc == enc) { - return i; - } - } - return 0; -} - void rb_enc_associate(VALUE obj, rb_encoding *enc) { |