Kaynağa Gözat

LibJS: Use PropertyName::as_string() in Object::get()

After we've already checked is_string(), we can use as_string() to
avoid a temporary String.
Andreas Kling 4 yıl önce
ebeveyn
işleme
42fcc2219d

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Object.cpp

@@ -765,7 +765,7 @@ Value Object::get(const PropertyName& property_name, Value receiver, bool withou
         return get_by_index(property_name.as_number());
         return get_by_index(property_name.as_number());
 
 
     if (property_name.is_string()) {
     if (property_name.is_string()) {
-        auto property_string = property_name.to_string();
+        auto& property_string = property_name.as_string();
         i32 property_index = property_string.to_int().value_or(-1);
         i32 property_index = property_string.to_int().value_or(-1);
         if (property_index >= 0)
         if (property_index >= 0)
             return get_by_index(property_index);
             return get_by_index(property_index);