[PATCH] D18756: [Coverage] Avoid unnecessary copying of an array. NFC.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 09:15:52 PDT 2016


This seems like more than a performance fix - the API itself seems a little
problematic. If buildSegments was called more than once on the same
SegmentBuilder, tehre would be trouble, right? (before this patch, it could
build on top of existing segments - after this patch it will use a
moved-from-vector which might be in some non-empty state (moved from
objects are in a "valid but unspecified" state - I'm not sure there's
anything other than empty that a vector could be in, but it's still a bit
subtle/risky))

Could the API be redesigned so it doesn't have this problem?

On Mon, Apr 4, 2016 at 8:07 AM, Igor Kudrin via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> ikudrin created this revision.
> ikudrin added reviewers: bogner, davidxl.
> ikudrin added a subscriber: llvm-commits.
>
> http://reviews.llvm.org/D18756
>
> Files:
>   llvm/trunk/lib/ProfileData/CoverageMapping.cpp
>
> Index: llvm/trunk/lib/ProfileData/CoverageMapping.cpp
> ===================================================================
> --- llvm/trunk/lib/ProfileData/CoverageMapping.cpp
> +++ llvm/trunk/lib/ProfileData/CoverageMapping.cpp
> @@ -341,7 +341,7 @@
>      // Pop any regions that are left in the stack.
>      while (!ActiveRegions.empty())
>        popRegion();
> -    return Segments;
> +    return std::move(Segments);
>    }
>  };
>  }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160404/50bf4b3c/attachment.html>


More information about the llvm-commits mailing list