[Laszlo-dev] For Review: Change 20080823-bargull-ZMZ Summary: add RegExp support to swf8

André Bargull andre.bargull at udo.edu
Wed Aug 27 08:09:02 PDT 2008


> Is the external call only required for swf8?  swf9 has RegExp?

Yep, adobe-ref: 
"http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/RegExp.html".


 > Do we know the speed penalty for the external call?

Unfortunately it's not only the plain call, but also some extra masking 
to workaround external-interface bugs.


> It would be interesting to meter the common pattern of using .split.join 
> against .replace.

This is quite dependent on the input-parameters:

1st testcase: "1 2 4 6 8".replace(/\d/g, "{$&}")
split-join:
> var k = "1 2 4 6 8";
> for (var j = 0; j < 9; ++j)
>   k = k.split(j).join("{" + j + "}");

The swf8 RegExp was ~100% slower compared to the split-join alternative.
(Without the extra-masking it was only ~80%!)

2nd testcase:
"[i] [ii] [iii] [iv] [v] [vi] [vii] [viii] [ix] 
[x]".replace(/\[(\w*)\]/, "($1)")
split-join:
> split("[").join("(").split("]").join(")")

swf8 RegExp was about five times slower compared to split-join.




On 8/27/2008 2:11 PM, P T Withington wrote:
> This is really great stuff.
> 
> Some questions:
> 
> Is the external call only required for swf8?  swf9 has RegExp?
> 
> Do we know the speed penalty for the external call?  For instance, in 
> the debugger I just rewrote a few simple patterns when making some 
> JS-only code generic.  [The RegExp patterns are more succinct, but, 
> perhaps the debugger should not rely on this level of infrastructure any 
> ways.]
> 

> 
> On 2008-08-23, at 17:12EDT, André Bargull wrote:
> 
>> Change 20080823-bargull-ZMZ by bargull at dell--p4--2-53 on 2008-08-23 
>> 21:13:55
>> in /home/Admin/src/svn/openlaszlo/trunk
>> for http://svn.openlaszlo.org/openlaszlo/trunk
>>
>> Summary: add RegExp support to swf8
>>
>> New Features: LPP-1584, LPP-6546
>>
>> Bugs Fixed:
>>
>> Technical Reviewer: max
>> QA Reviewer: rbitter
>> Doc Reviewer: (pending)
>>
>> Documentation:
>>
>> Release Notes:
>>
>> Details:
>> Adds support for RegExp to swf8 by using Flash's ExternalInterface to 
>> proxy regular expressions to the browser.
>> Also defines "String.prototype.match", "String.prototype.replace" and 
>> "String.prototype.search".
>> Internally a simple cache is used to reuse compiled RegExps on the 
>> browser-part (LzCache).
>> Some extra work was necessary to workaround ExternalInterface bugs, 
>> this is documented in "LzRegExp.lzs".
>>
>>
>> Tests:
>> buildlfc swf8 + cd lps/includes/source; ant clean build
>> test/regexp.lzx
>>
>> Files:
>> A WEB-INF/lps/lfc/kernel/swf/LzRegExp.lzs
>> M WEB-INF/lps/lfc/kernel/swf/Library.lzs
>> A WEB-INF/lps/lfc/helpers/LzCache.lzs
>> M WEB-INF/lps/lfc/helpers/Library.lzs
>> A lps/includes/source/regexp.js
>> M lps/includes/source/embed-library.lzs
>> A test/regexp.lzx
>>
>> Changeset: 
>> http://svn.openlaszlo.org/openlaszlo/patches/20080823-bargull-ZMZ.tar
>>
>>
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: regexp_perf.lzx
Type: text/xml
Size: 2484 bytes
Desc: not available
Url : http://www.openlaszlo.org/pipermail/laszlo-dev/attachments/20080827/6c51fa1e/regexp_perf-0001.xml


More information about the Laszlo-dev mailing list