ruby-changes:36419
From: nobu <ko1@a...>
Date: Thu, 20 Nov 2014 00:26:54 +0900 (JST)
Subject: [ruby-changes:36419] nobu:r48500 (trunk): parse.y: append directly to delayed content
nobu 2014-11-20 00:26:41 +0900 (Thu, 20 Nov 2014) New Revision: 48500 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48500 Log: parse.y: append directly to delayed content * parse.y (parser_here_document): append byte sequence directly to the delayed content instead of creating an intermediate string object. Modified files: trunk/ChangeLog trunk/parse.y Index: ChangeLog =================================================================== --- ChangeLog (revision 48499) +++ ChangeLog (revision 48500) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Nov 20 00:26:37 2014 Nobuyoshi Nakada <nobu@r...> + + * parse.y (parser_here_document): append byte sequence directly to + the delayed content instead of creating an intermediate string + object. + Wed Nov 19 21:11:01 2014 NARUSE, Yui <naruse@r...> * common.mk (ext/json/parser/parser.c): don't touch parse.c, Index: parse.y =================================================================== --- parse.y (revision 48499) +++ parse.y (revision 48500) @@ -6588,11 +6588,21 @@ parser_here_document(struct parser_param https://github.com/ruby/ruby/blob/trunk/parse.y#L6588 ripper_dispatch_scan_event(parser, tSTRING_CONTENT); } else { - if (str || - ((len = lex_p - parser->tokp) > 0 && - (str = STR_NEW3(parser->tokp, len, enc, func), 1))) { + if (str) { rb_str_append(parser->delayed, str); } + else if ((len = lex_p - parser->tokp) > 0) { + if (!(func & STR_FUNC_REGEXP) && rb_enc_asciicompat(enc)) { + int cr = ENC_CODERANGE_UNKNOWN; + rb_str_coderange_scan_restartable(parser->tokp, lex_p, enc, &cr); + if (cr != ENC_CODERANGE_7BIT && + current_enc == rb_usascii_encoding() && + enc != rb_utf8_encoding()) { + enc = rb_ascii8bit_encoding(); + } + } + rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); + } ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); } lex_goto_eol(parser); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/