8
8
// ===----------------------------------------------------------------------===//
9
9
10
10
#include " llvm/DebugInfo/PDB/Raw/NameMap.h"
11
- #include " llvm/ADT/BitVector .h"
11
+ #include " llvm/ADT/SparseBitVector .h"
12
12
#include " llvm/DebugInfo/CodeView/StreamReader.h"
13
13
#include " llvm/DebugInfo/PDB/Raw/RawError.h"
14
14
@@ -68,16 +68,16 @@ Error NameMap::load(codeview::StreamReader &Stream) {
68
68
return make_error<RawError>(raw_error_code::corrupt_file,
69
69
" Number of present words is too large" );
70
70
71
- // Store all the 'present' bits in a vector for later processing.
72
- SmallVector<uint32_t , 1 > PresentWords;
71
+ SparseBitVector<> Present;
73
72
for (uint32_t I = 0 ; I != NumPresentWords; ++I) {
74
73
uint32_t Word;
75
74
if (auto EC = Stream.readInteger (Word))
76
75
return joinErrors (std::move (EC),
77
76
make_error<RawError>(raw_error_code::corrupt_file,
78
77
" Expected name map word" ));
79
-
80
- PresentWords.push_back (Word);
78
+ for (unsigned Idx = 0 ; Idx < 32 ; ++Idx)
79
+ if (Word & (1U << Idx))
80
+ Present.set ((I * 32 ) + Idx);
81
81
}
82
82
83
83
// This appears to be a hash table which uses bitfields to determine whether
@@ -93,30 +93,21 @@ Error NameMap::load(codeview::StreamReader &Stream) {
93
93
return make_error<RawError>(raw_error_code::corrupt_file,
94
94
" Number of deleted words is too large" );
95
95
96
- // Store all the 'deleted' bits in a vector for later processing.
97
- SmallVector<uint32_t , 1 > DeletedWords;
96
+ SparseBitVector<> Deleted;
98
97
for (uint32_t I = 0 ; I != NumDeletedWords; ++I) {
99
98
uint32_t Word;
100
99
if (auto EC = Stream.readInteger (Word))
101
100
return joinErrors (std::move (EC),
102
101
make_error<RawError>(raw_error_code::corrupt_file,
103
- " Expected name map deleted word" ));
104
-
105
- DeletedWords.push_back (Word);
102
+ " Expected name map word" ));
103
+ for (unsigned Idx = 0 ; Idx < 32 ; ++Idx)
104
+ if (Word & (1U << Idx))
105
+ Deleted.set ((I * 32 ) + Idx);
106
106
}
107
107
108
- BitVector Present (MaxNumberOfStrings, false );
109
- if (!PresentWords.empty ())
110
- Present.setBitsInMask (PresentWords.data (), PresentWords.size ());
111
- BitVector Deleted (MaxNumberOfStrings, false );
112
- if (!DeletedWords.empty ())
113
- Deleted.setBitsInMask (DeletedWords.data (), DeletedWords.size ());
114
-
115
- for (uint32_t I = 0 ; I < MaxNumberOfStrings; ++I) {
116
- if (!Present.test (I))
117
- continue ;
118
-
108
+ for (unsigned I : Present) {
119
109
// For all present entries, dump out their mapping.
110
+ (void )I;
120
111
121
112
// This appears to be an offset relative to the start of the strings.
122
113
// It tells us where the null-terminated string begins.
0 commit comments