<div dir="ltr"><div>llvm::Record::isSubClassOf(StringRef Name) looks like this:<br></div><div><div><br></div><div><div><font face="monospace, monospace">  bool isSubClassOf(StringRef Name) const {</font></div><div><font face="monospace, monospace">    for (const auto &SCPair : SuperClasses) {</font></div><div><span style="font-family:monospace,monospace">      if (SCPair.first->getNameInitAsString() == Name)</span><br></div><div><font face="monospace, monospace">        return true;</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace">    return false;</font></div><div><font face="monospace, monospace">  }</font></div></div><div><br></div><div><div>Where getNameInitAsString copy constructs a new std::string. We're only using that temporary in a comparison. Is there a better way?</div></div><div><br></div><div>This function is called quite frequently, so it becomes costly.</div><div><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><span style="font-size:12.8px">Sincerely,</span><br style="font-size:12.8px"><span style="font-size:12.8px">Alexander Riccio</span><br style="font-size:12.8px"><span style="font-size:12.8px">--</span><br style="font-size:12.8px"><span style="font-size:12.8px">"Change the world or go home."</span><div style="font-size:12.8px"><a href="http://about.me/ariccio" target="_blank">about.me/ariccio</a></div><div style="font-size:12.8px"><a href="http://about.me/ariccio" target="_blank"><br></a></div><div style="font-size:12.8px">If left to my own devices, I will build more.</div><div style="font-size:12.8px">⁂</div></div></div></div></div></div>
</div></div></div>