forked from hajimehoshi/ebiten
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of allocating the result on heap for the user, allow the caller side to decide whether it should be heap-allocated or stack-allocated. This new method allows us to have a zero-alloc SubImage routine for the use cases where we don't want to make an extra allocation. The performance difference is measurable (comparison is done with benchstat): name old time/op new time/op delta SubImage-12 203ns ± 2% 33ns ± 2% -83.91% (p=0.000 n=20+19) name old alloc/op new alloc/op delta SubImage-12 112B ± 0% 0B -100.00% (p=0.000 n=20+20) Using SubImage is `~203ns`, SubImageInto is `~33ns`. SubImage does 1 allocation, SubImageInto does none. SubImage is rewritten in a way to avoid the code duplication. It should work identically to the previous contract (it returns nil if `i` is disposed, etc.) Fixes hajimehoshi#2902
- Loading branch information
Showing
2 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
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