ソースを参照

LibELF: Use member initialization for AuxiliaryVector::optional_string

When the member is initialized in the constructor body, but also has a
default constructor, you pay for default construction to just throw it
away. In this case a StringView is light weight to initialize, but we
might as well fix all cases we find.

Found by PVS-Studio: https://pvs-studio.com/en/docs/warnings/v818/
Brian Gianforcaro 3 年 前
コミット
d347432a9e
1 ファイル変更1 行追加1 行削除
  1. 1 1
      Userland/Libraries/LibELF/AuxiliaryVector.h

+ 1 - 1
Userland/Libraries/LibELF/AuxiliaryVector.h

@@ -90,10 +90,10 @@ struct AuxiliaryValue {
         auxv.a_un.a_ptr = (void*)ptr;
         auxv.a_un.a_ptr = (void*)ptr;
     }
     }
     AuxiliaryValue(Type type, StringView string)
     AuxiliaryValue(Type type, StringView string)
+        : optional_string(string)
     {
     {
         auxv.a_type = type;
         auxv.a_type = type;
         auxv.a_un.a_ptr = nullptr;
         auxv.a_un.a_ptr = nullptr;
-        optional_string = string;
     }
     }
 
 
     auxv_t auxv {};
     auxv_t auxv {};