[llvm] [MC] Use range-based for loops (NFC) (PR #98604)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 12 09:40:03 PDT 2024
================
@@ -699,17 +699,16 @@ void MCELFStreamer::setAttributeItems(unsigned Attribute, unsigned IntValue,
MCELFStreamer::AttributeItem *
MCELFStreamer::getAttributeItem(unsigned Attribute) {
- for (size_t I = 0; I < Contents.size(); ++I)
- if (Contents[I].Tag == Attribute)
- return &Contents[I];
+ for (AttributeItem &Item : Contents)
----------------
MaskRay wrote:
Using `llvm::find_if` requires a comparison with `Contents.end()` here and might be longer.
The for each loop LGTM.
https://github.com/llvm/llvm-project/pull/98604
More information about the llvm-commits
mailing list