Re: [PATCH] Some string changes/optimizations
| From: | Nuno Lopes | Date: | Thu, 10 Jul 2008 16:05:26 +0000 |
| Subject: | Re: [PATCH] Some string changes/optimizations | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-38904@lists.php.net to get a copy of this message | ||
Patch seems ok to me, although I haven't tested it. But let's see what Dmitry thinks about it.
I'm not sure about the removal of the nowdoc tokens, though. Somebody may me relying on them for pretty-printing..
Nuno
----- Original Message ----- From: "Matt Wilmas" <php_lists@realplain.com>
To: <internals@lists.php.net>
Cc: "Dmitry Stogov" <dmitry@zend.com>; "Nuno Lopes" <nlopess@php.net>
Sent: Thursday, July 10, 2008 1:45 PM
Subject: Re: [PHP-DEV] [PATCH] Some string changes/optimizations
Hi all, I had been meaning to update this patch for a while (after conflicting updates to some files), and finally did. :-) See original message for more details... There's been one change for strings -- before, I was moving the first ADD_* op into INIT_STRING, but wasn't too satisfied with that. So I eliminated the INIT_STRING opcode after realizing that simply setting the string to NULL makes it create a new string in add_string_to_string (the first ADD_* has op1 set to IS_UNUSED; otherwise it's still IS_TMP_VAR, though it's not "used" after my changes). Is this OK? The other prior changes seem fine to me: syntax highlighting consistency, combining the duplicate heredoc/nowdoc stuff and removing the NOWDOC tokens, allowing static heredocs to be used in static contexts, etc.? http://realplain.com/php/string_optimizations.diff http://realplain.com/php/string_optimizations_5_3.diff Remember to regenerate the scanner/parser with re2c/bison and run zend_vm_gen.php! I also included possible NEWS updates in the 5.3 patch this time. :-P Thanks for any feedback, Matt ----- Original Message ----- From: "Matt Wilmas" Sent: Monday, May 05, 2008Hi all, This patch... Saves one opcode per interpolated string [snip, old info] Next, after nowdoc support was added, I noticed it was mostly duplicate heredoc code in the scanner, so I combined them for the most part,removingthe NOWDOC tokens, etc. Is that OK? It seems like they may have justbeenthere for the parser... but I updated the parser so that static heredocs also work like nowdocs. Also removed the ST_START_[HEREDOC|NOWDOC] states in the scanner, by doing their work (to catch immediate ending label) intheinitial heredoc rule. While removing the NOWDOC references from zend_highlight.c, I made alittlechange that I think improves (err... adds) highlighting of variables in double-quoted strings, and makes literal text in heredocs/backticks the correct "highlight_string" color. This makes coloring consistent acrossallstrings. :-) Before/after example:http://realplain.com/php/highlight.htmlSpeaking of backticks, while updating their parser grammar, they nowbehavemore precisely like shell_exec(), in thatcmd(constant string) or$cmd(one variable) won't use INIT_STRING and create a temporary variable... Oh, almost forgot a couple things -- for HEAD: [snip] moved HANDLE_NEWLINES() so nowdoc text is copied first, otherwise the linenumberwould be off if there's an error in zend_copy_scanner_string. [snip] http://realplain.com/php/string_optimizations.diff http://realplain.com/php/string_optimizations_5_3.diff Thanks, Matt P.S. (for Marcus?), the ({LABEL}|([']{LABEL}['])|(["]{LABEL}["])) part of the heredoc rule crashed re2c (Windows) until I added the extra ( ), which shouldn't be needed AFAIK and was fine with just 2 alternate matches...