Skip to content

Commit d201c35

Browse files
committed
refactor(): rm clone usages
1 parent 42b328c commit d201c35

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

intersect.js

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,6 @@ function hasProperty(obj, property) {
2323
return Object.prototype.hasOwnProperty.call(obj, property);
2424
}
2525

26-
function clone(obj) {
27-
28-
if (typeof obj == 'function' || Object(obj) !== obj) {
29-
return obj;
30-
}
31-
32-
var res = new obj.constructor;
33-
34-
for (var key in obj) {
35-
if (hasProperty(obj, key)) {
36-
res[key] = clone(obj[key]);
37-
}
38-
}
39-
40-
return res;
41-
}
42-
4326
function repush(array, item) {
4427
for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {
4528
return array.push(array.splice(i, 1)[0]);
@@ -78,10 +61,6 @@ function parsePathString(pathString) {
7861
var paramCounts = { a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0 },
7962
data = [];
8063

81-
if (isArray(pathString) && isArray(pathString[0])) { // rough assumption
82-
data = clone(pathString);
83-
}
84-
8564
if (!data.length) {
8665

8766
String(pathString).replace(pathCommand, function(a, b, c) {
@@ -159,7 +138,16 @@ function pathToString() {
159138
}
160139

161140
function pathClone(pathArray) {
162-
var res = clone(pathArray);
141+
const res = new Array(pathArray.length);
142+
for (let i = 0; i < pathArray.length; i++) {
143+
const sourceRow = pathArray[i];
144+
const destinationRow = new Array(sourceRow.length);
145+
res[i] = destinationRow;
146+
for (let j = 0; j < sourceRow.length; j++) {
147+
destinationRow[j] = sourceRow[j];
148+
}
149+
}
150+
163151
res.toString = pathToString;
164152
return res;
165153
}

0 commit comments

Comments
 (0)