From 092ada6d2f31212754e17ab944168463c2d2d327 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 30 Jul 2023 08:27:31 -0700 Subject: Micro-optimize LineOffsetTable.generate 5.00 ms 100.0% 0 s bun (81023) 2.00 ms 40.0% 2.00 ms WTF::HashTableAddResult, WTF::Packed, WTF::IdentityExtractor, WTF::DefaultHash>, WTF::HashTraits>, WTF::HashTraits>>, WTF::Packed, WTF::Packed, WTF::IdentityExtractor, WTF::DefaultHash>, WTF::HashTraits>, WTF::HashTraits>>> WTF::HashTable, WTF::Packed, WTF::IdentityExtractor, WTF::DefaultHash>, WTF::HashTraits>, WTF::HashTraits>>::addPassingHashCode>, WTF::HashTranslatorCharBuffer const&, WTF::HashTranslatorCharBuffer const&>(WTF::HashTranslatorCharBuffer const&, WTF::HashTranslatorCharBuffer const&) 2.00 ms 40.0% 2.00 ms heap.StackFallbackAllocator(1024).free 2.00 ms 40.0% 0 s em.Allocator.rawFree 2.00 ms 40.0% 0 s em.Allocator.log2a 2.00 ms 40.0% 0 s em.Allocator.free__anon_1330765 2.00 ms 40.0% 0 s em.Allocator.resize__anon_1069235 2.00 ms 40.0% 0 s array_list.ArrayListAligned(i32,null).toOwnedSlice --- src/sourcemap/sourcemap.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sourcemap/sourcemap.zig b/src/sourcemap/sourcemap.zig index 178422848..c090397b3 100644 --- a/src/sourcemap/sourcemap.zig +++ b/src/sourcemap/sourcemap.zig @@ -933,7 +933,10 @@ pub const LineOffsetTable = struct { continue; } - var owned = columns_for_non_ascii.toOwnedSlice() catch unreachable; + // We don't call .toOwnedSlice() because it is expensive to + // reallocate the array AND when inside an Arena, it's + // hideously expensive + var owned = columns_for_non_ascii.items; if (stack_fallback.fixed_buffer_allocator.ownsSlice(std.mem.sliceAsBytes(owned))) { owned = allocator.dupe(i32, owned) catch unreachable; } -- cgit v1.2.3