[llvm] [DebugNames] Compare TableEntry names more efficiently (PR #79759)

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 12:37:13 PST 2024


================
@@ -543,6 +543,19 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
       return StrData.getCStr(&Off);
     }
 
+    /// Compares the name of this entry against Target, returning true if they
+    /// are equal. This is helpful is hot code paths that do not need the length
+    /// of the name.
+    bool sameNameAs(StringRef Target) const {
+      // Note: this is not the name, but the rest of debug_str starting from
+      // name. This handles corrupt data (non-null terminated) without
+      // overrunning the buffer.
+      auto Data = StrData.getData().substr(StringOffset);
+      auto TargetSize = Target.size();
----------------
felipepiovezan wrote:

Yeah... I guess you are right, I will change it. It just makes me uncomfortable how easy it is to trigger implicit conversions the moment I write any types here :( 

https://github.com/llvm/llvm-project/pull/79759


More information about the llvm-commits mailing list