1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 13:54:57 +00:00

Kernel: Use a StringView for Ext2FSDirectoryEntry::name

This is a temporary struct, so there's no need to allocate a long term
storage for these strings.
This commit is contained in:
Idan Horowitz 2022-01-11 22:01:44 +02:00
parent 8a4654a924
commit d1d24eaef4

View file

@ -24,7 +24,7 @@ static constexpr size_t max_block_size = 4096;
static constexpr size_t max_inline_symlink_length = 60;
struct Ext2FSDirectoryEntry {
String name;
StringView name;
InodeIndex inode_index { 0 };
u8 file_type { 0 };
u16 record_length { 0 };
@ -1463,8 +1463,8 @@ ErrorOr<NonnullRefPtr<Inode>> Ext2FS::create_directory(Ext2FSInode& parent_inode
dbgln_if(EXT2_DEBUG, "Ext2FS: create_directory: created new directory named '{} with inode {}", name, inode->index());
Vector<Ext2FSDirectoryEntry> entries;
TRY(entries.try_empend(".", inode->index(), static_cast<u8>(EXT2_FT_DIR)));
TRY(entries.try_empend("..", parent_inode.index(), static_cast<u8>(EXT2_FT_DIR)));
TRY(entries.try_empend("."sv, inode->index(), static_cast<u8>(EXT2_FT_DIR)));
TRY(entries.try_empend(".."sv, parent_inode.index(), static_cast<u8>(EXT2_FT_DIR)));
TRY(static_cast<Ext2FSInode&>(*inode).write_directory(entries));
TRY(parent_inode.increment_link_count());