-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: remove next-pow-2 dependency (#21)
This is such a small function that it's not worth having an external dependency.
- Loading branch information
Ian Johnson
authored
Dec 27, 2021
1 parent
7662e7e
commit d24a176
Showing
8 changed files
with
26,478 additions
and
11,392 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-env jest */ | ||
import { ceilPow2 } from "./util"; | ||
|
||
describe("ceilPow2", () => { | ||
test("returns the next power of 2 at least as large as the input", () => { | ||
expect(ceilPow2(1)).toBe(1); | ||
expect(ceilPow2(2)).toBe(2); | ||
expect(ceilPow2(5)).toBe(8); | ||
expect(ceilPow2(255)).toBe(256); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export function ceilPow2(v: number): number { | ||
// https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 | ||
v--; | ||
v |= v >> 1; | ||
v |= v >> 2; | ||
v |= v >> 4; | ||
v |= v >> 8; | ||
v |= v >> 16; | ||
v++; | ||
return v; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.