mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibJS: Add Object::fast_is<Set>() and Object::fast_is<Map>()
These are often hit by object serialization code path.
This commit is contained in:
parent
aec20e032b
commit
b549d51cdc
Notes:
github-actions[bot]
2025-09-26 15:27:03 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: b549d51cdc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6304
3 changed files with 12 additions and 0 deletions
|
|
@ -25,6 +25,8 @@ public:
|
|||
|
||||
virtual ~Map() override = default;
|
||||
|
||||
virtual bool is_map_object() const final { return true; }
|
||||
|
||||
void map_clear();
|
||||
bool map_remove(Value const&);
|
||||
Optional<Value> map_get(Value const&) const;
|
||||
|
|
@ -116,4 +118,7 @@ private:
|
|||
HashMap<Value, Value, ValueTraits> m_entries;
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool Object::fast_is<Map>() const { return is_map_object(); }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,6 +227,8 @@ public:
|
|||
virtual bool is_ecmascript_function_object() const { return false; }
|
||||
virtual bool is_array_iterator() const { return false; }
|
||||
virtual bool is_raw_json_object() const { return false; }
|
||||
virtual bool is_set_object() const { return false; }
|
||||
virtual bool is_map_object() const { return false; }
|
||||
|
||||
virtual bool eligible_for_own_property_enumeration_fast_path() const { return true; }
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ public:
|
|||
virtual void initialize(Realm&) override;
|
||||
virtual ~Set() override = default;
|
||||
|
||||
virtual bool is_set_object() const final { return true; }
|
||||
|
||||
// NOTE: Unlike what the spec says, we implement Sets using an underlying map,
|
||||
// so all the functions below do not directly implement the operations as
|
||||
// defined by the specification.
|
||||
|
|
@ -59,4 +61,7 @@ struct SetRecord {
|
|||
ThrowCompletionOr<SetRecord> get_set_record(VM&, Value);
|
||||
bool set_data_has(GC::Ref<Set>, Value);
|
||||
|
||||
template<>
|
||||
inline bool Object::fast_is<Set>() const { return is_set_object(); }
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue