Skip to content

Commit

Permalink
perf: faster resetIconPosition avoiding to parse path twice (#10497)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Sep 4, 2024
1 parent 026b45e commit f776f81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/svg-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ function getIconSize(iconKey) {
return { width: x1 - x0, height: y1 - y0 }
}

function resetIconPosition(path) {
function resetIconPosition(d) {
const path = svgpath(d)
const [offsetX, offsetY] = svgPathBbox(path)
const pathReset = svgpath(path).translate(-offsetX, -offsetY).toString()
const pathReset = path.translate(-offsetX, -offsetY).toString()
return pathReset
}

Expand Down
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"semver": "~7.6.3",
"simple-icons": "13.7.0",
"smol-toml": "1.3.0",
"svg-path-bbox": "^2.0.0",
"svg-path-bbox": "^2.1.0",
"svgpath": "^2.6.0",
"webextension-store-meta": "^1.2.3",
"xpath": "~0.0.34"
Expand Down

0 comments on commit f776f81

Please sign in to comment.