Skip to content

Commit

Permalink
perf(): clone => clonePoint, rm JSON.stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Jan 21, 2024
1 parent 4e76729 commit b779da2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bezier.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ class Bezier {
// move all points by distance 'd' wrt the origin 'o',
// and move end points by fixed distance along normal.
[0, 1].forEach(function (t) {
const p = (np[t * order] = utils.copy(points[t * order]));
const p = (np[t * order] = utils.clonePoint(points[t * order]));
p.x += (t ? r2 : r1) * v[t].n.x;
p.y += (t ? r2 : r1) * v[t].n.y;
});
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ const utils = {
return "[" + points.map(utils.pointToString).join(", ") + "]";
},

copy: function (obj) {
return JSON.parse(JSON.stringify(obj));
clonePoint: function (point) {
return { x: point.x, y: point.y };
},

angle: function (o, v1, v2) {
Expand Down

0 comments on commit b779da2

Please sign in to comment.