-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xml Parsing with large embedded SVG and Data URI can be very slow #7
Comments
_JSSyntaxRegExp._ExecuteMatch 98% CPU time |
Reduced file to just large icons. And left in a tag by mistake. |
Hacking the parser |
Thought maybe quote scanning was an issue. So I hacked in a probably not correct /**
* Returns a parser that accepts any input element except element.
*
* For example, `anyExcept()` succeeds and consumes any given letter
* except element. It only fails for an empty input.
* Equivalent to any().starLazy(char(element.codeUnitAt(0))
*/
Parser anyExcept(element,[String message = 'input expected']) {
return new AnyExceptParser(element,message);
}
class AnyExceptParser extends Parser {
final String _message;
final String _element;
final int _code;
AnyExceptParser(element, this._message) :
_element = element,
_code = element.codeUnitAt(0);
@override
Result parseOn(Context context) {
var start = context.position;
var buffer = context.buffer;
if( start >= buffer.length ){
return context.failure(_message);
}
int len = buffer.length;
int stop = start;
while( stop < len && !identical(buffer[stop],_element) ) {
stop++;
}
var result = context.buffer is String
? context.buffer.substring(start, stop)
: context.buffer.sublist(start, stop);
return context.success(result, stop);
}
@override
Parser copy() => new AnyExceptParser(_element,_message);
@override
bool equalProperties(AnyExceptParser other) {
return super.equalProperties(other)
&& _code == other._code
&& _message == other._message;
}
} |
It is _decodeXml! .seq(any().starLazy(char(DOUBLE_QUOTE)).flatten())
// .seq(any().starLazy(char(DOUBLE_QUOTE)).flatten().map(_decodeXml))
|
Sent a pull request which ~fixes this issue. |
Final results after new decode.
|
Working for now. |
I could really use this performance fix. :-)
I don't have a file I can share just as yet, but this diagram.xml file has a large embedded SVG and images encoded as URI.
Unfortunately, those large strings are attributes and not text elements.
I realize I should probably change the XML model, but I can't anytime soon.
Diagram: 2420642 diagram_export_1.xml
The text was updated successfully, but these errors were encountered: