mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
AK: Try to use StringViews more for substrings and splitting.
This commit is contained in:
parent
a082738f04
commit
33920df299
Notes:
sideshowbarker
2024-07-19 14:41:32 +09:00
Author: https://github.com/awesomekling
Commit: 33920df299
9 changed files with 133 additions and 13 deletions
|
@ -1,5 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
class String;
|
||||
|
||||
class StringView {
|
||||
public:
|
||||
StringView() { }
|
||||
|
@ -19,7 +25,20 @@ public:
|
|||
int length() const { return m_length; }
|
||||
char operator[](int index) const { return m_characters[index]; }
|
||||
|
||||
StringView substring_view(int start, int length) const;
|
||||
Vector<StringView> split_view(char) const;
|
||||
unsigned to_uint(bool& ok) const;
|
||||
|
||||
bool operator==(const char* cstring) const { return !strcmp(m_characters, cstring); }
|
||||
bool operator!=(const char* cstring) const { return strcmp(m_characters, cstring); }
|
||||
|
||||
bool operator==(const String&) const;
|
||||
|
||||
private:
|
||||
const char* m_characters { nullptr };
|
||||
int m_length { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using AK::StringView;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue