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

LibArchive: Refactor Tar to make DRY (Don't Repeat Yourself)

Problem:
- The getters and setters duplicate code for conversions.
- Getters are returning `const StringView` rather than non-`const`.

Solution:
- Factor out common code to helper functions.
- Return `StringView` as non-`const`.
This commit is contained in:
Lenny Maiorani 2022-02-15 10:10:35 -07:00 committed by Idan Horowitz
parent 0ec688f86e
commit 583e197897
2 changed files with 72 additions and 50 deletions

View file

@ -103,8 +103,8 @@ void TarInputStream::advance()
bool TarInputStream::valid() const
{
auto& header_magic = header().magic();
auto& header_version = header().version();
auto const header_magic = header().magic();
auto const header_version = header().version();
if (!((header_magic == gnu_magic && header_version == gnu_version)
|| (header_magic == ustar_magic && header_version == ustar_version)