1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:27:35 +00:00

LibPDF: Store indirect value refs in Value objects

IndirectValueRef is so simple that it can be stored directly in the
Value class instead of being heap allocated.

As the comment in Value says, however, in theory the max bits needed to
store is 48 (16 for the generation index and 32(?) for the object
index), but 32 should be good enough for now. We can increase it to u64
later if necessary.
This commit is contained in:
Matthew Olsson 2021-05-23 16:12:25 -07:00 committed by Ali Mohammad Pur
parent 534a2e95d2
commit be6e4b6f3c
7 changed files with 56 additions and 54 deletions

View file

@ -222,26 +222,6 @@ private:
Value m_value;
};
class IndirectValueRef final : public Object {
public:
IndirectValueRef(u32 index, u32 generation_index)
: m_index(index)
{
set_generation_index(generation_index);
}
~IndirectValueRef() override = default;
[[nodiscard]] ALWAYS_INLINE u32 index() const { return m_index; }
ALWAYS_INLINE bool is_indirect_value_ref() const override { return true; }
ALWAYS_INLINE const char* type_name() const override { return "indirect_object_ref"; }
String to_string(int indent) const override;
private:
u32 m_index;
};
template<IsObject To, IsObject From>
[[nodiscard]] ALWAYS_INLINE static NonnullRefPtr<To> object_cast(NonnullRefPtr<From> obj
#ifdef PDF_DEBUG