Skip to content

Commit 3e47883

Browse files
authored
Recover performance loss after PagedVector introduction (#67972)
1 parent 4137309 commit 3e47883

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clang/include/clang/Basic/SourceManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
724724
///
725725
/// Negative FileIDs are indexes into this table. To get from ID to an index,
726726
/// use (-ID - 2).
727-
llvm::PagedVector<SrcMgr::SLocEntry> LoadedSLocEntryTable;
727+
llvm::PagedVector<SrcMgr::SLocEntry, 32> LoadedSLocEntryTable;
728728

729729
/// For each allocation in LoadedSLocEntryTable, we keep the first FileID.
730730
/// We assume exactly one allocation per AST file, and use that to determine

llvm/include/llvm/ADT/PagedVector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ template <typename T, size_t PageSize = 1024 / sizeof(T)> class PagedVector {
8484
assert(Index / PageSize < PageToDataPtrs.size());
8585
T *&PagePtr = PageToDataPtrs[Index / PageSize];
8686
// If the page was not yet allocated, allocate it.
87-
if (!PagePtr) {
87+
if (LLVM_UNLIKELY(!PagePtr)) {
8888
PagePtr = Allocator.getPointer()->template Allocate<T>(PageSize);
8989
// We need to invoke the default constructor on all the elements of the
9090
// page.

0 commit comments

Comments
 (0)