mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
LibPDF: Add facility to obtain Vector<float> from ArrayObject
Arrays of float numbers are common in many PDF objects, and thus to avoid code repetition I'm introducing a new method to ArrayObject that will return exactly that.
This commit is contained in:
parent
a63b93f724
commit
17676705a5
Notes:
sideshowbarker
2024-07-17 05:21:12 +09:00
Author: https://github.com/rtobar Commit: https://github.com/SerenityOS/serenity/commit/17676705a5 Pull-request: https://github.com/SerenityOS/serenity/pull/16202
@ -50,6 +50,16 @@ DeprecatedString NameObject::to_deprecated_string(int) const
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
Vector<float> ArrayObject::float_elements() const
|
||||
{
|
||||
Vector<float> values;
|
||||
values.ensure_capacity(m_elements.size());
|
||||
for (auto const& value : m_elements) {
|
||||
values.append(value.to_float());
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
DeprecatedString ArrayObject::to_deprecated_string(int indent) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE size_t size() const { return m_elements.size(); }
|
||||
[[nodiscard]] ALWAYS_INLINE Vector<Value> elements() const { return m_elements; }
|
||||
[[nodiscard]] Vector<float> float_elements() const;
|
||||
|
||||
ALWAYS_INLINE auto begin() const { return m_elements.begin(); }
|
||||
ALWAYS_INLINE auto end() const { return m_elements.end(); }
|
||||
|
Loading…
Reference in New Issue
Block a user