Skip to content

Commit

Permalink
Yet another pass of style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Dec 21, 2018
1 parent 89040cd commit ec1c487
Show file tree
Hide file tree
Showing 43 changed files with 183 additions and 185 deletions.
16 changes: 8 additions & 8 deletions AK/AKString.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,33 @@ class String {

unsigned toUInt(bool& ok) const;

String toLowercase() const
String to_lowercase() const
{
if (!m_impl)
return String();
return m_impl->toLowercase();
return m_impl->to_lowercase();
}

String toUppercase() const
String to_uppercase() const
{
if (!m_impl)
return String();
return m_impl->toUppercase();
return m_impl->to_uppercase();
}

Vector<String> split(char separator) const;
String substring(size_t start, size_t length) const;

bool isNull() const { return !m_impl; }
bool isEmpty() const { return length() == 0; }
bool is_null() const { return !m_impl; }
bool is_empty() const { return length() == 0; }
unsigned length() const { return m_impl ? m_impl->length() : 0; }
const char* characters() const { return m_impl ? m_impl->characters() : nullptr; }
char operator[](unsigned i) const { ASSERT(m_impl); return (*m_impl)[i]; }

bool operator==(const String&) const;
bool operator!=(const String& other) const { return !(*this == other); }

String isolatedCopy() const;
String isolated_copy() const;

static String empty();

Expand All @@ -93,7 +93,7 @@ class String {
return *this;
}

ByteBuffer toByteBuffer() const;
ByteBuffer to_byte_buffer() const;

private:
RetainPtr<StringImpl> m_impl;
Expand Down
12 changes: 6 additions & 6 deletions AK/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace AK {
template<typename T>
class Buffer : public Retainable<Buffer<T>> {
public:
static RetainPtr<Buffer> createUninitialized(size_t count);
static RetainPtr<Buffer> create_uninitialized(size_t count);
static RetainPtr<Buffer> copy(const T*, size_t count);
static RetainPtr<Buffer> wrap(T*, size_t count);
static RetainPtr<Buffer> adopt(T*, size_t count);
Expand All @@ -29,16 +29,16 @@ class Buffer : public Retainable<Buffer<T>> {

T& operator[](size_t i) { ASSERT(i < m_size); return m_elements[i]; }
const T& operator[](size_t i) const { ASSERT(i < m_size); return m_elements[i]; }
bool isEmpty() const { return !m_size; }
bool is_empty() const { return !m_size; }
size_t size() const { return m_size; }

T* pointer() { return m_elements; }
const T* pointer() const { return m_elements; }

T* offsetPointer(size_t offset) { return m_elements + offset; }
const T* offsetPointer(size_t offset) const { return m_elements + offset; }
T* offset_pointer(size_t offset) { return m_elements + offset; }
const T* offset_pointer(size_t offset) const { return m_elements + offset; }

const void* endPointer() const { return m_elements + m_size; }
const void* end_pointer() const { return m_elements + m_size; }

// NOTE: trim() does not reallocate.
void trim(size_t size)
Expand Down Expand Up @@ -91,7 +91,7 @@ inline Buffer<T>::Buffer(T* elements, size_t size, ConstructionMode mode)
}

template<typename T>
inline RetainPtr<Buffer<T>> Buffer<T>::createUninitialized(size_t size)
inline RetainPtr<Buffer<T>> Buffer<T>::create_uninitialized(size_t size)
{
return ::adopt(*new Buffer<T>(size));
}
Expand Down
21 changes: 10 additions & 11 deletions AK/ByteBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,30 @@ class ByteBuffer {
return *this;
}

static ByteBuffer createEmpty() { return ByteBuffer(Buffer<byte>::createUninitialized(0)); }
static ByteBuffer createUninitialized(size_t size) { return ByteBuffer(Buffer<byte>::createUninitialized(size)); }
static ByteBuffer create_uninitialized(size_t size) { return ByteBuffer(Buffer<byte>::create_uninitialized(size)); }
static ByteBuffer copy(const byte* data, size_t size) { return ByteBuffer(Buffer<byte>::copy(data, size)); }
static ByteBuffer wrap(byte* data, size_t size) { return ByteBuffer(Buffer<byte>::wrap(data, size)); }
static ByteBuffer adopt(byte* data, size_t size) { return ByteBuffer(Buffer<byte>::adopt(data, size)); }

~ByteBuffer() { clear(); }
void clear() { m_impl = nullptr; }

operator bool() const { return !isNull(); }
bool operator!() const { return isNull(); }
bool isNull() const { return m_impl == nullptr; }
operator bool() const { return !is_null(); }
bool operator!() const { return is_null(); }
bool is_null() const { return m_impl == nullptr; }

byte& operator[](size_t i) { ASSERT(m_impl); return (*m_impl)[i]; }
byte operator[](size_t i) const { ASSERT(m_impl); return (*m_impl)[i]; }
bool isEmpty() const { return !m_impl || m_impl->isEmpty(); }
bool is_empty() const { return !m_impl || m_impl->is_empty(); }
size_t size() const { return m_impl ? m_impl->size() : 0; }

byte* pointer() { return m_impl ? m_impl->pointer() : nullptr; }
const byte* pointer() const { return m_impl ? m_impl->pointer() : nullptr; }

byte* offsetPointer(size_t offset) { return m_impl ? m_impl->offsetPointer(offset) : nullptr; }
const byte* offsetPointer(size_t offset) const { return m_impl ? m_impl->offsetPointer(offset) : nullptr; }
byte* offset_pointer(size_t offset) { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
const byte* offset_pointer(size_t offset) const { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }

const void* endPointer() const { return m_impl ? m_impl->endPointer() : nullptr; }
const void* end_pointer() const { return m_impl ? m_impl->end_pointer() : nullptr; }

// NOTE: trim() does not reallocate.
void trim(size_t size)
Expand All @@ -65,13 +64,13 @@ class ByteBuffer {

ByteBuffer slice(size_t offset, size_t size) const
{
if (isNull())
if (is_null())
return { };
if (offset >= this->size())
return { };
if (offset + size >= this->size())
size = this->size() - offset;
return copy(offsetPointer(offset), size);
return copy(offset_pointer(offset), size);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion AK/DoublyLinkedList.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DoublyLinkedList {
DoublyLinkedList() { }
~DoublyLinkedList() { clear(); }

bool isEmpty() const { return !head(); }
bool is_empty() const { return !head(); }

void clear()
{
Expand Down
6 changes: 3 additions & 3 deletions AK/FileSystemPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ bool FileSystemPath::canonicalize(bool resolve_symbolic_links)
if (part == ".")
continue;
if (part == "..") {
if (!canonical_parts.isEmpty())
if (!canonical_parts.is_empty())
canonical_parts.takeLast();
continue;
}
if (!part.isEmpty())
if (!part.is_empty())
canonical_parts.append(part);
}
if (canonical_parts.isEmpty()) {
if (canonical_parts.is_empty()) {
m_string = m_basename = "/";
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion AK/HashMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class HashMap {
return *this;
}

bool isEmpty() const { return m_table.isEmpty(); }
bool is_empty() const { return m_table.is_empty(); }
unsigned size() const { return m_table.size(); }
unsigned capacity() const { return m_table.capacity(); }
void clear() { m_table.clear(); }
Expand Down
18 changes: 9 additions & 9 deletions AK/HashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class HashTable {
}

~HashTable() { clear(); }
bool isEmpty() const { return !m_size; }
bool is_empty() const { return !m_size; }
unsigned size() const { return m_size; }
unsigned capacity() const { return m_capacity; }

Expand Down Expand Up @@ -112,7 +112,7 @@ class HashTable {
, m_isEnd(isEnd)
, m_bucketIterator(bucketIterator)
{
if (!isEnd && !m_table.isEmpty() && !(m_bucketIterator != DoublyLinkedList<T>::Iterator::universalEnd())) {
if (!isEnd && !m_table.is_empty() && !(m_bucketIterator != DoublyLinkedList<T>::Iterator::universalEnd())) {
#ifdef HASHTABLE_DEBUG
kprintf("bucket iterator init!\n");
#endif
Expand All @@ -128,7 +128,7 @@ class HashTable {
typename DoublyLinkedList<T>::Iterator m_bucketIterator;
};

Iterator begin() { return Iterator(*this, isEmpty()); }
Iterator begin() { return Iterator(*this, is_empty()); }
Iterator end() { return Iterator(*this, true); }

class ConstIterator {
Expand Down Expand Up @@ -189,7 +189,7 @@ class HashTable {
, m_isEnd(isEnd)
, m_bucketIterator(bucketIterator)
{
if (!isEnd && !m_table.isEmpty() && !(m_bucketIterator != DoublyLinkedList<T>::ConstIterator::universalEnd())) {
if (!isEnd && !m_table.is_empty() && !(m_bucketIterator != DoublyLinkedList<T>::ConstIterator::universalEnd())) {
#ifdef HASHTABLE_DEBUG
kprintf("const bucket iterator init!\n");
#endif
Expand All @@ -206,7 +206,7 @@ class HashTable {
typename DoublyLinkedList<T>::ConstIterator m_bucketIterator;
};

ConstIterator begin() const { return ConstIterator(*this, isEmpty()); }
ConstIterator begin() const { return ConstIterator(*this, is_empty()); }
ConstIterator end() const { return ConstIterator(*this, true); }

Iterator find(const T&);
Expand Down Expand Up @@ -323,7 +323,7 @@ void HashTable<T, TraitsForT>::insert(const T& value)
template<typename T, typename TraitsForT>
bool HashTable<T, TraitsForT>::contains(const T& value) const
{
if (isEmpty())
if (is_empty())
return false;
auto& bucket = lookup(value);
for (auto& e : bucket.chain) {
Expand All @@ -336,7 +336,7 @@ bool HashTable<T, TraitsForT>::contains(const T& value) const
template<typename T, typename TraitsForT>
auto HashTable<T, TraitsForT>::find(const T& value) -> Iterator
{
if (isEmpty())
if (is_empty())
return end();
unsigned bucketIndex;
auto& bucket = lookup(value, &bucketIndex);
Expand All @@ -349,7 +349,7 @@ auto HashTable<T, TraitsForT>::find(const T& value) -> Iterator
template<typename T, typename TraitsForT>
auto HashTable<T, TraitsForT>::find(const T& value) const -> ConstIterator
{
if (isEmpty())
if (is_empty())
return end();
unsigned bucketIndex;
auto& bucket = lookup(value, &bucketIndex);
Expand All @@ -362,7 +362,7 @@ auto HashTable<T, TraitsForT>::find(const T& value) const -> ConstIterator
template<typename T, typename TraitsForT>
void HashTable<T, TraitsForT>::remove(Iterator it)
{
ASSERT(!isEmpty());
ASSERT(!is_empty());
m_buckets[it.m_bucketIndex].chain.remove(it.m_bucketIterator);
--m_size;
}
Expand Down
Loading

0 comments on commit ec1c487

Please sign in to comment.