Fixes #445 - speed issue in url processor.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 23 Jan 2015 22:55:39 +0000 (22:55 +0000)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 23 Jan 2015 22:55:39 +0000 (22:55 +0000)
Obviously we don't need to search for uppercase URLs constantly, just
if there is at least one.

History.md
lib/text/urls-processor.js

index 2fea22f..e5a2635 100644 (file)
@@ -11,6 +11,7 @@
 * Fixed issue [#435](https://github.com/GoalSmashers/clean-css/issues/435) - `background-clip` in shorthand.
 * Fixed issue [#439](https://github.com/GoalSmashers/clean-css/issues/439) - `background-origin` in shorthand.
 * Fixed issue [#442](https://github.com/GoalSmashers/clean-css/issues/442) - space before adjacent `nav`.
+* Fixed issue [#445](https://github.com/GoalSmashers/clean-css/issues/445) - regression issue in url processor.
 
 [3.0.7 / 2015-01-22](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.6...v3.0.7)
 ==================
index c5f4734..2399388 100644 (file)
@@ -25,10 +25,11 @@ UrlsProcessor.prototype.escape = function (data) {
   var lastBreakAt;
   var indent;
   var saveWaypoints = this.saveWaypoints;
+  var hasUppercaseUrl = data.indexOf(UPPERCASE_URL_PREFIX) > -1;
 
   for (; nextEnd < data.length;) {
     nextStart = data.indexOf(URL_PREFIX, nextEnd);
-    nextStartUpperCase = data.indexOf(UPPERCASE_URL_PREFIX, nextEnd);
+    nextStartUpperCase = hasUppercaseUrl ? data.indexOf(UPPERCASE_URL_PREFIX, nextEnd) : -1;
     if (nextStart == -1 && nextStartUpperCase == -1)
       break;