mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Micro-optimize LineOffsetTable.generate
5.00 ms 100.0% 0 s bun (81023) 2.00 ms 40.0% 2.00 ms WTF::HashTableAddResult<WTF::HashTableIterator<WTF::HashTable<WTF::Packed<WTF::StringImpl*>, WTF::Packed<WTF::StringImpl*>, WTF::IdentityExtractor, WTF::DefaultHash<WTF::Packed<WTF::StringImpl*>>, WTF::HashTraits<WTF::Packed<WTF::StringImpl*>>, WTF::HashTraits<WTF::Packed<WTF::StringImpl*>>>, WTF::Packed<WTF::StringImpl*>, WTF::Packed<WTF::StringImpl*>, WTF::IdentityExtractor, WTF::DefaultHash<WTF::Packed<WTF::StringImpl*>>, WTF::HashTraits<WTF::Packed<WTF::StringImpl*>>, WTF::HashTraits<WTF::Packed<WTF::StringImpl*>>>> WTF::HashTable<WTF::Packed<WTF::StringImpl*>, WTF::Packed<WTF::StringImpl*>, WTF::IdentityExtractor, WTF::DefaultHash<WTF::Packed<WTF::StringImpl*>>, WTF::HashTraits<WTF::Packed<WTF::StringImpl*>>, WTF::HashTraits<WTF::Packed<WTF::StringImpl*>>>::addPassingHashCode<WTF::HashSetTranslatorAdapter<WTF::BufferFromStaticDataTranslator<unsigned char>>, WTF::HashTranslatorCharBuffer<unsigned char> const&, WTF::HashTranslatorCharBuffer<unsigned char> const&>(WTF::HashTranslatorCharBuffer<unsigned char> const&, WTF::HashTranslatorCharBuffer<unsigned char> 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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user