-
Notifications
You must be signed in to change notification settings - Fork 80
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
Accept integers to h3GetResolution #113
Accept integers to h3GetResolution #113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no problem with this in general, but I do wonder if we should expose the split integer stuff or just use BigInt here? All major browsers support it, now.
test/h3core.spec.js
Outdated
test('h3GetResolution - integers', assert => { | ||
// Same as in h3GetResolution above | ||
const indexes = [ | ||
[4294967295, 134389759], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required here, but I think we should probably expose h3IndexToSplitLong
as a public function and use it here rather than hard-coding the input data. If this test fails, it'll be very hard for a future engineer to determine whether it's the fault of the code or the input.
lib/h3core.js
Outdated
) { | ||
const [lower, upper] = h3Index; | ||
return H3.h3GetResolution(lower, upper); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we just delegate all paths to the C implementation here? i.e.
const [lower, upper] = h3IndexToSplitLong(h3Index);
return H3.h3GetResolution(lower, upper);
I'm not sure why we implemented it in pure JS at first, but I'm not convinced it's any faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it's best to use a similar optimization strategy to other bindings rather than relying on puling characters out. Using the library implementation seems more predictable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for adding!
h3GetResolution had an unusual implementation that did not actually work for
H3IndexInput
type input. Fixed this and allow split integer input.