Skip to content

Commit 827bd48

Browse files
lologarithmdmitshur
authored andcommitted
compiler/natives/src/reflect: Optimize Swapper by swapping JS array elements directly (bypass reflection). (gopherjs#785)
The previous swapper implementation was a very generic one, implemented using reflection. Since we know the internal GopherJS representation of a slice, we can implement a much faster swapper that operates on the underlying JavaScript array directly, bypassing the overhead of the reflect machinery. The performance improvement when sorting large slices is extremely high. benchmark old ns/op new ns/op delta BenchmarkSortString1K_Slice 17220000 573500 -96.67% BenchmarkStableInt1K_Slice 82400000 835000 -98.99% BenchmarkSortInt64K_Slice 2084000000 37533333 -98.20%
1 parent 82b3220 commit 827bd48

File tree

3 files changed

+145
-106
lines changed

3 files changed

+145
-106
lines changed

0 commit comments

Comments
 (0)