Skip to content

Conversation

@matej21
Copy link
Contributor

@matej21 matej21 commented Jan 2, 2017

see matej21/neon-js#3

This regex may become very slow in a combination with end of string assertion

see this and this and compare number of steps (it increases exponentially)

Performance test:

$encoder = new \Nette\Neon\Encoder();
$var = str_repeat('a', 20) . ',';

$start = microtime(TRUE);
for ($i = 0; $i < 1000; $i++) {
	$encoder->encode($var);
}
echo microtime(TRUE) - $start;
echo "\n";

before: 3.8s
now: 0.005s

thanks @JirkaVebr for a help

@dg
Copy link
Member

dg commented Jan 2, 2017

https://regex101.com is awesome! Where it was my whole life?

@dg dg closed this in 3a2f839 Jan 2, 2017
@dg
Copy link
Member

dg commented Jan 2, 2017

I hope this fix will work 3a2f839

dg added a commit that referenced this pull request Jan 2, 2017
dg added a commit that referenced this pull request Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants