1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:08:10 +00:00

LibCore: Keep track of file offset to avoid system call for tell()

This optimization makes the new test run 2x faster.
This commit is contained in:
kleines Filmröllchen 2023-07-06 13:41:38 +02:00 committed by Jelle Raaijmakers
parent 111fd1e5fe
commit 10edd38543
3 changed files with 33 additions and 1 deletions

View file

@ -67,6 +67,7 @@ public:
virtual bool is_open() const override;
virtual void close() override;
virtual ErrorOr<size_t> seek(i64 offset, SeekMode) override;
virtual ErrorOr<size_t> tell() const override;
virtual ErrorOr<void> truncate(size_t length) override;
// Sets the blocking mode of the file. If blocking mode is disabled, reads
@ -109,6 +110,8 @@ private:
int m_fd { -1 };
bool m_last_read_was_eof { false };
ShouldCloseFileDescriptor m_should_close_file_descriptor { ShouldCloseFileDescriptor::Yes };
size_t m_file_offset { 0 };
};
AK_ENUM_BITWISE_OPERATORS(File::OpenMode)