Skip to content

Commit

Permalink
Minor speed improvement: only compute uniqueId (at most) once.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank3K committed Jul 1, 2014
1 parent 600fe66 commit 4ec1249
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tasks/svgstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module.exports = function (grunt) {
// Map to store references from id to uniqueId + id;
// N.B.: only IDs that are referenced are mapped.
var mappedIds = {};
var uniqueId;
$('*').each(function () {
var $elem = $(this);
var attrs = $elem.attr();
Expand All @@ -87,7 +88,9 @@ module.exports = function (grunt) {

// Add id mapping if not already present
if (!mappedIds[refId]) {
var uniqueId = md5(contentStr);
if (!uniqueId) {
uniqueId = md5(contentStr);
}
var newId = 'svgstore' + uniqueId + refId;
mappedIds[refId] = newId;
}
Expand Down

0 comments on commit 4ec1249

Please sign in to comment.