[llvm-dev] llvm::Record::isSubClassOf(StringRef Name) constructs a new std::string

<Alexander G. Riccio> via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 3 09:58:31 PST 2016


llvm::Record::isSubClassOf(StringRef Name) looks like this:

  bool isSubClassOf(StringRef Name) const {
    for (const auto &SCPair : SuperClasses) {
      if (SCPair.first->getNameInitAsString() == Name)
        return true;
    }
    return false;
  }

Where getNameInitAsString copy constructs a new std::string. We're only
using that temporary in a comparison. Is there a better way?

This function is called quite frequently, so it becomes costly.

Sincerely,
Alexander Riccio
--
"Change the world or go home."
about.me/ariccio

<http://about.me/ariccio>
If left to my own devices, I will build more.
⁂
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160203/d32586c6/attachment.html>


More information about the llvm-dev mailing list