summaryrefslogtreecommitdiff
path: root/Libraries/LibJS
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibJS')
-rw-r--r--Libraries/LibJS/Console.cpp2
-rw-r--r--Libraries/LibJS/Runtime/Exception.cpp2
-rw-r--r--Libraries/LibJS/Runtime/IndexedProperties.cpp12
-rw-r--r--Libraries/LibJS/Runtime/IndexedProperties.h6
4 files changed, 11 insertions, 11 deletions
diff --git a/Libraries/LibJS/Console.cpp b/Libraries/LibJS/Console.cpp
index 5033ed25c9..cd40739ebc 100644
--- a/Libraries/LibJS/Console.cpp
+++ b/Libraries/LibJS/Console.cpp
@@ -123,7 +123,7 @@ bool Console::counter_reset(String label)
Vector<String> ConsoleClient::get_trace() const
{
Vector<String> trace;
- auto call_stack = m_console.interpreter().call_stack();
+ auto& call_stack = m_console.interpreter().call_stack();
// -2 to skip the console.trace() call frame
for (ssize_t i = call_stack.size() - 2; i >= 0; --i)
trace.append(call_stack[i].function_name);
diff --git a/Libraries/LibJS/Runtime/Exception.cpp b/Libraries/LibJS/Runtime/Exception.cpp
index 99f7fbd789..a92ec65c2b 100644
--- a/Libraries/LibJS/Runtime/Exception.cpp
+++ b/Libraries/LibJS/Runtime/Exception.cpp
@@ -32,7 +32,7 @@ namespace JS {
Exception::Exception(Value value)
: m_value(value)
{
- auto call_stack = interpreter().call_stack();
+ auto& call_stack = interpreter().call_stack();
for (ssize_t i = call_stack.size() - 1; i >= 0; --i) {
auto function_name = call_stack[i].function_name;
if (function_name.is_empty())
diff --git a/Libraries/LibJS/Runtime/IndexedProperties.cpp b/Libraries/LibJS/Runtime/IndexedProperties.cpp
index 19f8b68e5b..5b327e302d 100644
--- a/Libraries/LibJS/Runtime/IndexedProperties.cpp
+++ b/Libraries/LibJS/Runtime/IndexedProperties.cpp
@@ -273,7 +273,7 @@ Optional<ValueAndAttributes> IndexedProperties::get(Object* this_object, u32 ind
return result;
if (!result.has_value())
return {};
- auto value = result.value();
+ auto& value = result.value();
if (value.value.is_accessor()) {
ASSERT(this_object);
auto& accessor = value.value.as_accessor();
@@ -315,7 +315,7 @@ void IndexedProperties::insert(u32 index, Value value, PropertyAttributes attrib
{
if (m_storage->is_simple_storage() && (index >= SPARSE_ARRAY_THRESHOLD || attributes != default_attributes || array_like_size() == SPARSE_ARRAY_THRESHOLD))
switch_to_generic_storage();
- m_storage->insert(index, value, attributes);
+ m_storage->insert(index, move(value), attributes);
}
ValueAndAttributes IndexedProperties::take_first(Object* this_object)
@@ -340,7 +340,7 @@ void IndexedProperties::append_all(Object* this_object, const IndexedProperties&
switch_to_generic_storage();
for (auto it = properties.begin(false); it != properties.end(); ++it) {
- auto element = it.value_and_attributes(this_object, evaluate_accessors);
+ const auto& element = it.value_and_attributes(this_object, evaluate_accessors);
if (this_object && this_object->interpreter().exception())
return;
m_storage->put(m_storage->array_like_size(), element.value, element.attributes);
@@ -357,14 +357,14 @@ void IndexedProperties::set_array_like_size(size_t new_size)
Vector<ValueAndAttributes> IndexedProperties::values_unordered() const
{
if (m_storage->is_simple_storage()) {
- auto elements = static_cast<const SimpleIndexedPropertyStorage&>(*m_storage).elements();
+ const auto& elements = static_cast<const SimpleIndexedPropertyStorage&>(*m_storage).elements();
Vector<ValueAndAttributes> with_attributes;
for (auto& value : elements)
with_attributes.append({ value, default_attributes });
return with_attributes;
}
- auto storage = static_cast<const GenericIndexedPropertyStorage&>(*m_storage);
+ auto& storage = static_cast<const GenericIndexedPropertyStorage&>(*m_storage);
auto values = storage.packed_elements();
values.ensure_capacity(values.size() + storage.sparse_elements().size());
for (auto& entry : storage.sparse_elements())
@@ -374,7 +374,7 @@ Vector<ValueAndAttributes> IndexedProperties::values_unordered() const
void IndexedProperties::switch_to_generic_storage()
{
- auto storage = static_cast<const SimpleIndexedPropertyStorage&>(*m_storage);
+ auto& storage = static_cast<SimpleIndexedPropertyStorage&>(*m_storage);
m_storage = make<GenericIndexedPropertyStorage>(move(storage));
}
diff --git a/Libraries/LibJS/Runtime/IndexedProperties.h b/Libraries/LibJS/Runtime/IndexedProperties.h
index d95f0d83a7..a6d89b77c3 100644
--- a/Libraries/LibJS/Runtime/IndexedProperties.h
+++ b/Libraries/LibJS/Runtime/IndexedProperties.h
@@ -83,7 +83,7 @@ public:
virtual void set_array_like_size(size_t new_size) override;
virtual bool is_simple_storage() const override { return true; }
- Vector<Value> elements() const { return m_packed_elements; }
+ const Vector<Value>& elements() const { return m_packed_elements; }
private:
friend GenericIndexedPropertyStorage;
@@ -109,8 +109,8 @@ public:
virtual size_t array_like_size() const override { return m_array_size; }
virtual void set_array_like_size(size_t new_size) override;
- Vector<ValueAndAttributes> packed_elements() const { return m_packed_elements; }
- HashMap<u32, ValueAndAttributes> sparse_elements() const { return m_sparse_elements; }
+ const Vector<ValueAndAttributes>& packed_elements() const { return m_packed_elements; }
+ const HashMap<u32, ValueAndAttributes>& sparse_elements() const { return m_sparse_elements; }
private:
size_t m_array_size { 0 };