Skip to content

refactor: simplify round function and make it faster #564

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

Merged
merged 3 commits into from
Apr 21, 2023

Conversation

tarikjabiri
Copy link
Contributor

No description provided.

@tarikjabiri
Copy link
Contributor Author

@microsoft-github-policy-service agree

@danmarshall
Copy link
Contributor

Hi @tarikjabiri , thanks so much for this valuable contribution! This is definitely one of the most significant bottlenecks in the code. (see #412 ). It is similar to the original code but I didn't use Epsilon for ES5 compatibility.

I'm not sure if people still need support for ES5. I will keep this PR open while I investigate.
I probably should have used a polyfill for epsilon at the time, but Maker.js started with an early TypeScript version and has an antique build system by today's standards.

Note, here is the reference code on MDN from the Wayback machine which has been removed in the current document.

@danmarshall
Copy link
Contributor

Instead of adding a polyfill to Number, I've arrived at defining a scoped variable EPSILON, which can be Number.EPSILON || Math.pow(2, -52). Would you be willing to add this in?

@tarikjabiri
Copy link
Contributor Author

Thats a good idea, done

@danmarshall
Copy link
Contributor

Perfect, thank you!!

@danmarshall danmarshall merged commit 7852c73 into microsoft:master Apr 21, 2023
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.

2 participants