Forráskód Böngészése

LibELF: Avoid calling strlen() in DynamicObject::hash_section()

The long-term fix here is to make StringView recognize compile-time
string literals and do the right thing automatically.
Andreas Kling 4 éve
szülő
commit
cc00df0f0f
1 módosított fájl, 3 hozzáadás és 1 törlés
  1. 3 1
      Userland/Libraries/LibELF/DynamicObject.cpp

+ 3 - 1
Userland/Libraries/LibELF/DynamicObject.cpp

@@ -235,7 +235,9 @@ DynamicObject::Section DynamicObject::fini_array_section() const
 
 
 DynamicObject::HashSection DynamicObject::hash_section() const
 DynamicObject::HashSection DynamicObject::hash_section() const
 {
 {
-    const char* section_name = m_hash_type == HashType::SYSV ? "DT_HASH" : "DT_GNU_HASH";
+    auto section_name = m_hash_type == HashType::SYSV
+        ? StringView { "DT_HASH", 7 }
+        : StringView { "DT_GNU_HASH", 11 };
     return HashSection(Section(*this, m_hash_table_offset, 0, 0, section_name), m_hash_type);
     return HashSection(Section(*this, m_hash_table_offset, 0, 0, section_name), m_hash_type);
 }
 }