Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #2
Summary
This PR refactors the core date structures in llvm-block to improve performance and memory usage.
std::vector<collist*> table
withTableMap = std::unordered_map<int, collist*>
(keyed by line number).std::list<col*>cols
insidecollist
with `std::unordered_map<int, col*> (keyed by column number)CreateTable
,InsertTable
,CompareLR
) to use fastmap.find()
instead of linear scans or repeatedresize()
.Motivation
vector
approach wasted memory and spent time resizing.std::list
lookups insearchcol()
were O(n) in the number of columns; switching tounordered_map
yields amortized O(1) lookups.What's Changed
llvm-block.cpp
std::vector<collist*> table
forusing TableMap = std::unordered_map<int, collist*>
table.at(line)
+resize()
pattern withtable.find(line)
+ insert-if-missing.CreateTable()
,InsertTable()
, andCompareLR()
to use the new map.table.h/table.cpp
collist::cols
fromstd::list<col*>
tostd::unordered_map<int, col*>
push(col*)
andsearchcol(int)
to usecols.find()
for O(1) insert / lookup.