-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Problem
Using a std::vector requires resizing and allocating entries even for line numbers that may never be used.
This becomes inefficient and potentially wasteful when debug line numbers are sparse, which is common in optimized builds.
Suggested Solution
Replace the std::vector<collist*> table with either:
std::map<int, std::unique_ptr<collist>>(if ordered traversal is important)- or
std::unordered_map<int, std::unique_ptr<collist>>(for faster access)
This allows:
- Dynamic and sparse indexing with no wasted memory
- Logarithmic (or constant) time lookup of line numbers (originally ran with linear time complexity)
- Cleaner and more flexible code (no need to pre-reserve or resize vector)
Furthermore:
- It can be applied to
colsincollistsby changing intostd::map<int, col*> - This allows faster search in
searchcol()method with logarithmic time complexity
ML2jinmyoungML2jinmyoung