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

Change package to use no_std #20

Merged
merged 6 commits into from
Aug 9, 2021
Merged

Change package to use no_std #20

merged 6 commits into from
Aug 9, 2021

Conversation

notgull
Copy link
Contributor

@notgull notgull commented Jul 26, 2021

This pull requests replaces all dependencies on libstd to dependencies on libcore and liballoc, so that this algorithm can be used on targets that do not have access to the standard library.

@andreesteve andreesteve linked an issue Jul 28, 2021 that may be closed by this pull request
@mourner
Copy link
Owner

mourner commented Jul 30, 2021

Or, if micromath is brought up solely for the square root, as an alternative we could use a simple bitwise integer square root algorithm inline, it's a few lines (citing JS here but Rust should be equivalent):

function isqrt(n) {
    if (n < 2) return n;
    const sc = isqrt(n >> 2) << 1, lc = sc + 1;
    return lc * lc > n ? sc : lc;
}

@notgull
Copy link
Contributor Author

notgull commented Jul 31, 2021

Or, if micromath is brought up solely for the square root, as an alternative we could use a simple bitwise integer square root algorithm inline, it's a few lines (citing JS here but Rust should be equivalent):

function isqrt(n) {
    if (n < 2) return n;
    const sc = isqrt(n >> 2) << 1, lc = sc + 1;
    return lc * lc > n ? sc : lc;
}

1). We also depend on "floor()" from micromath (although we could implement that ourselves trivially if need be)

2). I think micromath's operations are O(1), while this looks to be O(n).

@mourner
Copy link
Owner

mourner commented Jul 31, 2021

I think micromath's operations are O(1), while this looks to be O(n).

It's log(n), and only called once per the whole triangulation so it shouldn't have any impact on performance. I also don't know how much the micromath floating point code brings in terms of binary size, which is also a consideration, but no strong feelings on this.

Copy link
Collaborator

@andreesteve andreesteve left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. LGTM

@mourner mourner merged commit ddb4fea into mourner:master Aug 9, 2021
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.

no_std support
3 participants