ruby-changes:2901
From: ko1@a...
Date: 21 Dec 2007 13:03:30 +0900
Subject: [ruby-changes:2901] matz - Ruby:r14392 (trunk): * string.c (rb_str_chomp_bang): avoid unnecessary loop using
matz 2007-12-21 13:03:19 +0900 (Fri, 21 Dec 2007) New Revision: 14392 Modified files: trunk/ChangeLog trunk/string.c Log: * string.c (rb_str_chomp_bang): avoid unnecessary loop using rb_enc_prev_char(). http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=14392&r2=14391 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14392&r2=14391 Index: ChangeLog =================================================================== --- ChangeLog (revision 14391) +++ ChangeLog (revision 14392) @@ -2,6 +2,11 @@ * lib/runit, lib/rubyunit.rb, test/testunit/runit: removed. +Fri Dec 21 12:45:49 2007 Yukihiro Matsumoto <matz@r...> + + * string.c (rb_str_chomp_bang): avoid unnecessary loop using + rb_enc_prev_char(). + Fri Dec 21 12:32:08 2007 Yukihiro Matsumoto <matz@r...> * file.c (Init_File): File.exists? revived. Index: string.c =================================================================== --- string.c (revision 14391) +++ string.c (revision 14392) @@ -4538,12 +4538,8 @@ if (p[len-1] == newline && (rslen <= 1 || memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) { - if (rb_enc_mbmaxlen(enc) > 1) { - while (p < pp) { - p += rb_enc_mbclen(p, e, enc); - } - if (p != pp) return Qnil; - } + if (ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,p,pp) != (const UChar*)pp) + return Qnil; rb_str_modify(str); STR_SET_LEN(str, RSTRING_LEN(str) - rslen); RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0'; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml