Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(convertPathData): account for error in z conversions #1842

Merged
merged 7 commits into from Nov 28, 2023

Conversation

KTibow
Copy link
Contributor

@KTibow KTibow commented Nov 19, 2023

You know how 0.1 + 0.2 = 0.30000000000000004? I was trying to prove that an icon can be optimized more, got curious why it wasn't getting converted to z, and found the culprit: ===.
This PR fixes it using error to check for closeness.

Results

-130b from Arch Linux
-450b from Isometric Madness
-7b from Wikipedia

@KTibow
Copy link
Contributor Author

KTibow commented Nov 19, 2023

Facing weird test behavior on convertPathData.11. When I change the expected output to one thing it produces the unexpected. When I change it to that it starts producing the other output.

@KTibow
Copy link
Contributor Author

KTibow commented Nov 19, 2023

It's because it tests it both with multipass and without. The thing is that the matrix transform leads to it being 0.001106 away (not enough to convert to z) but once it's stringified it comes out to 0.001 away (enough to convert to z). I'll solve this by just making sure it can convert in all the cases.

@KTibow KTibow changed the title Account for error in z conversions fix: account for error in z conversions Nov 24, 2023
@KTibow KTibow changed the title fix: account for error in z conversions fix(convertPathData): account for error in z conversions Nov 24, 2023
Copy link
Member

@SethFalco SethFalco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change makes sense, nice catch!

And yeah, the multipass tests tripped me up as well lately, I experienced the same behavior. ^-^'

That's in place since we want to make sure the plugin does everything it could want to do in a single execution, i.e. running SVGO with multipass but just a single plugin should be redundant.

Just a question regarding the modified test, others happy to merge!

test/plugins/convertPathData.11.svg Outdated Show resolved Hide resolved
@SethFalco SethFalco merged commit 86d5040 into svg:main Nov 28, 2023
10 checks passed
@SethFalco
Copy link
Member

Looks good to me, thanks for working on this!
This will be released in SVGO v3.0.5. (ETA, 1 December 2023)

nono added a commit to cozy/cozy-stack that referenced this pull request Dec 4, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [svgo](https://svgo.dev) ([source](https://togithub.com/svg/svgo)) |
[`3.0.4` -> `3.0.5`](https://renovatebot.com/diffs/npm/svgo/3.0.4/3.0.5)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/svgo/3.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/svgo/3.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/svgo/3.0.4/3.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/svgo/3.0.4/3.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>svg/svgo (svgo)</summary>

### [`v3.0.5`](https://togithub.com/svg/svgo/releases/tag/v3.0.5)

[Compare Source](https://togithub.com/svg/svgo/compare/v3.0.4...v3.0.5)

#### What's Changed

##### Bug Fixes

- **[Cleanup IDs](https://svgo.dev/docs/plugins/cleanup-ids/)**,
correctly handle references to other nodes in animations. By
[@&#8203;KTibow](https://togithub.com/KTibow) in
[svg/svgo#1862
- **[Convert Path
Commands](https://svgo.dev/docs/plugins/convert-path-data/)**, fix issue
when removing redundant `Z` between mergable `M`/`m` commands. By
[@&#8203;KTibow](https://togithub.com/KTibow) in
[svg/svgo#1856
- **[Convert Path
Commands](https://svgo.dev/docs/plugins/convert-path-data/)**, adhere to
error/precision in `z` conversions. By
[@&#8203;KTibow](https://togithub.com/KTibow) in
[svg/svgo#1842
- **[Remove Empty
Containers](https://svgo.dev/docs/plugins/remove-empty-containers/)**,
skip if parent node is `<switch>`, as empty containers can be used for
attributes like `requiredFeatures`. By
[@&#8203;vincentbernat](https://togithub.com/vincentbernat) in
[svg/svgo#1747
- **[Remove Hidden
Elements](https://svgo.dev/docs/plugins/remove-hidden-elems/)**, when
removing a hidden definition, also remove nodes that reference it. By
[@&#8203;SethFalco](https://togithub.com/SethFalco) in
[svg/svgo#1852
- Output the optimization stats (profit) in red if the file size
increased. By [@&#8203;gimler](https://togithub.com/gimler) in
[svg/svgo#1162
- Type definition files now correctly use the `.d.ts` file extension
instead of `.ts`. By [@&#8203;Exotelis](https://togithub.com/Exotelis)
in
[svg/svgo#1780

##### Chores

- Improved exported types for the `#loadConfig` method. By
[@&#8203;nuintun](https://togithub.com/nuintun) in
[svg/svgo#1844

#### Metrics

Before and after using vectors from various sources, with the default
preset of each respective version:

| SVG | Original | v3.0.4 | v3.0.5 | Delta |
|---|---|---|---|---|
| [Arch Linux Logo](https://archlinux.org/art/) | 9.529 KiB | 4.735 KiB
| 4.608 KiB | ⬇️ 0.127 KiB |
|
[Blobs](https://gitlab.gnome.org/GNOME/gnome-backgrounds/-/blob/main/backgrounds/blobs-d.svg)
| 50.45 KiB | 42.949 KiB | 42.949 KiB | |
| [Isometric
Madness](https://inkscape.org/~Denis_Kuznetsky/%E2%98%85isometric-madness)
| 869.034 KiB | 550.593 KiB | 550.153 KiB | ⬇️ 0.44 KiB |
| [tldr-pages
Banner](https://togithub.com/tldr-pages/tldr/blob/main/images/banner.svg)
| 2.071 KiB | 1.07 KiB | 1.07 KiB | |
| [Wikipedia
Logo](https://en.wikipedia.org/wiki/File:Wikipedia-logo-v2.svg) |
161.551 KiB | 117.152 KiB | 117.146 KiB | ⬇️ 0.006 KiB |

Before and after of the browser bundle of each respective version:

| | v3.0.4 | v3.0.5 | Delta |
|---|---|---|---|
| svgo.browser.js | 656.9 kB | 657.5 kB | ⬆️ 0.6 kB |

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 6am on Monday" in timezone
Europe/Paris, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/cozy/cozy-stack).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44MS4zIiwidXBkYXRlZEluVmVyIjoiMzcuODEuMyIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants