Shorten while(true) to for(;;)

This commit is contained in:
Matthias Mullie 2015-04-07 15:35:03 +02:00
parent ecd1a04d88
commit 2a70744313
2 changed files with 9 additions and 0 deletions

View File

@ -415,6 +415,9 @@ class JS extends Minify
$content = preg_replace('/\btrue\b/', '!0', $content);
$content = preg_replace('/\bfalse\b/', '!1', $content);
// for(;;) is exactly the same as while(true)
$content = preg_replace('/\bwhile\(!0\)/', 'for(;;)', $content);
return $content;
}
}

View File

@ -388,6 +388,12 @@ if(e.which==40&&index<$items.length-1)index++',
'array["dont-replace"].key2',
);
// shorten bools
$tests[] = array(
'while(true){break}',
'for(;;){break}',
);
// https://github.com/matthiasmullie/minify/issues/10
$tests[] = array(
'// first mutation patch