[PATCH] D49046: Use StringRef instead of `const char *`.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 6 15:14:24 PDT 2018


ruiu created this revision.
ruiu added a reviewer: grimar.
Herald added subscribers: JDevlieghere, hiraditya.

I don't think there's a need to use `const char *`. In most (probably all?)
cases, we need a length of a name later, so discarding a length will
lead to a wasted effort.


https://reviews.llvm.org/D49046

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
  llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp


Index: llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
@@ -37,7 +37,7 @@
       if (DieRef == 0)
         break;
       uint8_t IndexEntryValue = GnuStyle ? PubNames.getU8(&Offset) : 0;
-      const char *Name = PubNames.getCStr(&Offset);
+      StringRef Name = PubNames.getCStrRef(&Offset);
       SetData.Entries.push_back(
           {DieRef, PubIndexEntryDescriptor(IndexEntryValue), Name});
     }
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
@@ -32,7 +32,7 @@
 
     /// The name of the object as given by the DW_AT_name attribute of the
     /// referenced DIE.
-    const char *Name;
+    StringRef Name;
   };
 
   /// Each table consists of sets of variable length entries. Each set describes


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49046.154464.patch
Type: text/x-patch
Size: 1079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180706/3b61deaa/attachment.bin>


More information about the llvm-commits mailing list