Kernel: Convert Inode event APIs to use StringViews instead of Strings

These APIs allocate a copy internally anyways, so there's no point to
making another one for them.
This commit is contained in:
Idan Horowitz 2022-01-11 22:04:53 +02:00
parent d1d24eaef4
commit e236f9d85a
4 changed files with 7 additions and 6 deletions

View file

@ -202,7 +202,7 @@ void Inode::set_metadata_dirty(bool metadata_dirty)
}
}
void Inode::did_add_child(InodeIdentifier, String const& name)
void Inode::did_add_child(InodeIdentifier, StringView name)
{
MutexLocker locker(m_inode_lock);
@ -211,7 +211,7 @@ void Inode::did_add_child(InodeIdentifier, String const& name)
}
}
void Inode::did_remove_child(InodeIdentifier, String const& name)
void Inode::did_remove_child(InodeIdentifier, StringView name)
{
MutexLocker locker(m_inode_lock);

View file

@ -106,8 +106,8 @@ protected:
void set_metadata_dirty(bool);
ErrorOr<void> prepare_to_write_data();
void did_add_child(InodeIdentifier child_id, String const& name);
void did_remove_child(InodeIdentifier child_id, String const& name);
void did_add_child(InodeIdentifier child_id, StringView);
void did_remove_child(InodeIdentifier child_id, StringView);
void did_modify_contents();
void did_delete_self();

View file

@ -86,7 +86,7 @@ ErrorOr<NonnullOwnPtr<KString>> InodeWatcher::pseudo_path(const OpenFileDescript
return KString::formatted("InodeWatcher:({})", m_wd_to_watches.size());
}
void InodeWatcher::notify_inode_event(Badge<Inode>, InodeIdentifier inode_id, InodeWatcherEvent::Type event_type, String const& name)
void InodeWatcher::notify_inode_event(Badge<Inode>, InodeIdentifier inode_id, InodeWatcherEvent::Type event_type, StringView name)
{
MutexLocker locker(m_lock);

View file

@ -12,6 +12,7 @@
#include <AK/CircularQueue.h>
#include <AK/HashMap.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/String.h>
#include <Kernel/API/InodeWatcherEvent.h>
#include <Kernel/FileSystem/File.h>
#include <Kernel/Forward.h>
@ -54,7 +55,7 @@ public:
virtual StringView class_name() const override { return "InodeWatcher"sv; };
virtual bool is_inode_watcher() const override { return true; }
void notify_inode_event(Badge<Inode>, InodeIdentifier, InodeWatcherEvent::Type, String const& name = {});
void notify_inode_event(Badge<Inode>, InodeIdentifier, InodeWatcherEvent::Type, StringView name = {});
ErrorOr<int> register_inode(Inode&, unsigned event_mask);
ErrorOr<void> unregister_by_wd(int);