mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:08:12 +00:00
AK: Add case insensitive String::ends_with support
FileSystemPath::has_extension was jumping through hoops and allocating memory to do a case insensitive comparison needlessly. Extend the existing String::ends_with method to allow the caller to specify the case sensitivity required.
This commit is contained in:
parent
8e4b858b3f
commit
332f96e7ca
7 changed files with 53 additions and 12 deletions
|
@ -105,11 +105,9 @@ void FileSystemPath::canonicalize()
|
|||
m_string = builder.to_string();
|
||||
}
|
||||
|
||||
bool FileSystemPath::has_extension(StringView extension) const
|
||||
bool FileSystemPath::has_extension(const StringView& extension) const
|
||||
{
|
||||
// FIXME: This is inefficient, expand StringView with enough functionality that we don't need to copy strings here.
|
||||
String extension_string = extension;
|
||||
return m_string.to_lowercase().ends_with(extension_string.to_lowercase());
|
||||
return m_string.ends_with(extension, CaseSensitivity::CaseInsensitive);
|
||||
}
|
||||
|
||||
String canonicalized_path(const StringView& path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue