Skip to content

feat: replace std::vector<collist*> with std::map or std::unordered_map #2

@minseoc03

Description

@minseoc03

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 cols in collists by changing into std::map<int, col*>
  • This allows faster search in searchcol() method with logarithmic time complexity

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions