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

More moving towards using signed types.

I'm still feeling this out, but I am starting to like the general idea.
This commit is contained in:
Andreas Kling 2019-02-25 22:06:55 +01:00
parent beda478821
commit 9624b54703
48 changed files with 234 additions and 250 deletions

View file

@ -10,9 +10,9 @@ enum ShouldChomp { NoChomp, Chomp };
class StringImpl : public Retainable<StringImpl> {
public:
static Retained<StringImpl> create_uninitialized(size_t length, char*& buffer);
static Retained<StringImpl> create_uninitialized(ssize_t length, char*& buffer);
static RetainPtr<StringImpl> create(const char* cstring, ShouldChomp = NoChomp);
static RetainPtr<StringImpl> create(const char* cstring, size_t length, ShouldChomp = NoChomp);
static RetainPtr<StringImpl> create(const char* cstring, ssize_t length, ShouldChomp = NoChomp);
Retained<StringImpl> to_lowercase() const;
Retained<StringImpl> to_uppercase() const;
@ -20,9 +20,9 @@ public:
~StringImpl();
size_t length() const { return m_length; }
ssize_t length() const { return m_length; }
const char* characters() const { return m_characters; }
char operator[](size_t i) const { ASSERT(i < m_length); return m_characters[i]; }
char operator[](ssize_t i) const { ASSERT(i >= 0 && i < m_length); return m_characters[i]; }
unsigned hash() const
{
@ -36,11 +36,11 @@ private:
explicit StringImpl(ConstructTheEmptyStringImplTag) : m_characters("") { }
enum ConstructWithInlineBufferTag { ConstructWithInlineBuffer };
StringImpl(ConstructWithInlineBufferTag, size_t length);
StringImpl(ConstructWithInlineBufferTag, ssize_t length);
void compute_hash() const;
size_t m_length { 0 };
ssize_t m_length { 0 };
mutable bool m_hasHash { false };
const char* m_characters { nullptr };
mutable unsigned m_hash { 0 };