[PATCH] Use map instead of vector to store line counts in llvm-cov

Bob Wilson bob.wilson at apple.com
Wed Oct 23 09:47:16 PDT 2013


On Oct 22, 2013, at 1:57 PM, Yuchen Wu <yuchenericwu at hotmail.com> wrote:

> Use a map instead of vector to store line counts.
> 
> 
> There are a few motivations for this:
> Using a map allows for checking if line is in map. This differentiates unexecutable lines (such as comments) from unexecuted logical lines of code. "#####" is now outputted in this case, as it is done in gcov.
> Source files are no longer read in twice: once when storing the line counts, and once when outputting the data.
> Greatly simplifies the function FileInfo::addLineCount().

I had some concerns about the performance of using a DenseMap for a very large source files, but after thinking about it, I think this is fine.  I suspect the difference won't even be measurable, and I like the idea of starting with simple code and then if it turns out to have performance issues, we can make it faster later.

Go ahead and commit this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131023/df0f8517/attachment.html>


More information about the llvm-commits mailing list