diff options
author | Andreas Kling <kling@serenityos.org> | 2021-04-29 22:23:52 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-29 22:23:52 +0200 |
commit | 3d4afe7614bf8ff4c6fe141d1dcd83688a7ac8cd (patch) | |
tree | b27345e76b10d2cd7c4381a70385c21d6310405a /Userland/Libraries | |
parent | 7ae7170d6140f7cad730f05f84b53437058b82f4 (diff) | |
download | serenity-3d4afe7614bf8ff4c6fe141d1dcd83688a7ac8cd.zip |
Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibC/elf.h | 14 | ||||
-rw-r--r-- | Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/AbstractView.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/FileSystemModel.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/FilteringProxyModel.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/IconView.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Model.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ModelSelection.cpp | 28 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ModelSelection.h | 28 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/SortingProxyModel.cpp | 24 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/SortingProxyModel.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/PNGLoader.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduce.js | 16 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduceRight.js | 16 |
14 files changed, 84 insertions, 84 deletions
diff --git a/Userland/Libraries/LibC/elf.h b/Userland/Libraries/LibC/elf.h index 6e3bcf729c..342dbd1f2e 100644 --- a/Userland/Libraries/LibC/elf.h +++ b/Userland/Libraries/LibC/elf.h @@ -67,7 +67,7 @@ typedef uint32_t Elf64_Half; typedef uint16_t Elf64_Quarter; /* - * e_ident[] identification indexes + * e_ident[] identification indices * See http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ #define EI_MAG0 0 /* file ID */ @@ -241,15 +241,15 @@ typedef struct { Elf64_Xword sh_entsize; /* table entry size */ } Elf64_Shdr; -/* Special Section Indexes */ +/* Special Section Indices */ #define SHN_UNDEF 0 /* undefined */ -#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ +#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indices */ #define SHN_LOPROC 0xff00 /* reserved range for processor */ -#define SHN_HIPROC 0xff1f /* specific section indexes */ +#define SHN_HIPROC 0xff1f /* specific section indices */ #define SHN_ABS 0xfff1 /* absolute value */ #define SHN_COMMON 0xfff2 /* common symbol */ #define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */ -#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */ +#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indices */ /* sh_type */ #define SHT_NULL 0 /* inactive */ @@ -269,7 +269,7 @@ typedef struct { #define SHT_FINI_ARRAY 15 /* pointers to termination functions */ #define SHT_PREINIT_ARRAY 16 /* ptrs to funcs called before init */ #define SHT_GROUP 17 /* defines a section group */ -#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */ +#define SHT_SYMTAB_SHNDX 18 /* Section indices (see SHN_XINDEX). */ #define SHT_LOOS 0x60000000 /* reserved range for OS specific */ #define SHT_SUNW_dof 0x6ffffff4 /* used by dtrace */ #define SHT_GNU_LIBLIST 0x6ffffff7 /* libraries to be prelinked */ @@ -282,7 +282,7 @@ typedef struct { #define SHT_LOPROC 0x70000000 /* reserved range for processor */ #define SHT_HIPROC 0x7fffffff /* specific section header types */ #define SHT_LOUSER 0x80000000 /* reserved range for application */ -#define SHT_HIUSER 0xffffffff /* specific indexes */ +#define SHT_HIUSER 0xffffffff /* specific indices */ #define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table section */ diff --git a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp index 989c6ec1c2..5f7408800a 100644 --- a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp @@ -578,7 +578,7 @@ FLATTEN void UnsignedBigInteger::shift_left_without_allocation( * Complexity: O(N^2) where N is the number of words in the larger number * Multiplication method: * An integer is equal to the sum of the powers of two - * according to the indexes of its 'on' bits. + * according to the indices of its 'on' bits. * So to multiple x*y, we go over each '1' bit in x (say the i'th bit), * and add y<<i to the result. */ diff --git a/Userland/Libraries/LibGUI/AbstractView.cpp b/Userland/Libraries/LibGUI/AbstractView.cpp index 17a9ea2616..43af9a15cc 100644 --- a/Userland/Libraries/LibGUI/AbstractView.cpp +++ b/Userland/Libraries/LibGUI/AbstractView.cpp @@ -43,13 +43,13 @@ void AbstractView::set_model(RefPtr<Model> model) m_model = move(model); if (m_model) m_model->register_view({}, *this); - model_did_update(GUI::Model::InvalidateAllIndexes); + model_did_update(GUI::Model::InvalidateAllIndices); scroll_to_top(); } void AbstractView::model_did_update(unsigned int flags) { - if (!model() || (flags & GUI::Model::InvalidateAllIndexes)) { + if (!model() || (flags & GUI::Model::InvalidateAllIndices)) { stop_editing(); m_edit_index = {}; m_hovered_index = {}; @@ -630,9 +630,9 @@ void AbstractView::do_search(String&& searching) return; } - auto found_indexes = model()->matches(searching, Model::MatchesFlag::FirstMatchOnly | Model::MatchesFlag::MatchAtStart | Model::MatchesFlag::CaseInsensitive, model()->parent_index(cursor_index())); - if (!found_indexes.is_empty() && found_indexes[0].is_valid()) { - auto& index = found_indexes[0]; + auto found_indices = model()->matches(searching, Model::MatchesFlag::FirstMatchOnly | Model::MatchesFlag::MatchAtStart | Model::MatchesFlag::CaseInsensitive, model()->parent_index(cursor_index())); + if (!found_indices.is_empty() && found_indices[0].is_valid()) { + auto& index = found_indices[0]; m_highlighted_search_index = index; m_searching = move(searching); set_selection(index); diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp index dd55c4eca2..4b63d81805 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.cpp +++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp @@ -629,17 +629,17 @@ Vector<ModelIndex, 1> FileSystemModel::matches(const StringView& searching, unsi { Node& node = const_cast<Node&>(this->node(index)); node.reify_if_needed(); - Vector<ModelIndex, 1> found_indexes; + Vector<ModelIndex, 1> found_indices; for (auto& child : node.children) { if (string_matches(child.name, searching, flags)) { const_cast<Node&>(child).reify_if_needed(); - found_indexes.append(child.index(Column::Name)); + found_indices.append(child.index(Column::Name)); if (flags & FirstMatchOnly) break; } } - return found_indexes; + return found_indices; } } diff --git a/Userland/Libraries/LibGUI/FilteringProxyModel.cpp b/Userland/Libraries/LibGUI/FilteringProxyModel.cpp index b36a2d73fa..229e193a70 100644 --- a/Userland/Libraries/LibGUI/FilteringProxyModel.cpp +++ b/Userland/Libraries/LibGUI/FilteringProxyModel.cpp @@ -106,10 +106,10 @@ bool FilteringProxyModel::is_searchable() const Vector<ModelIndex, 1> FilteringProxyModel::matches(const StringView& searching, unsigned flags, const ModelIndex& index) { - auto found_indexes = m_model.matches(searching, flags, index); - for (size_t i = 0; i < found_indexes.size(); i++) - found_indexes[i] = map(found_indexes[i]); - return found_indexes; + auto found_indices = m_model.matches(searching, flags, index); + for (size_t i = 0; i < found_indices.size(); i++) + found_indices[i] = map(found_indices[i]); + return found_indices; } } diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp index b0c13387f6..2506fb190b 100644 --- a/Userland/Libraries/LibGUI/IconView.cpp +++ b/Userland/Libraries/LibGUI/IconView.cpp @@ -122,7 +122,7 @@ auto IconView::item_data_from_content_position(const Gfx::IntPoint& content_posi void IconView::model_did_update(unsigned flags) { AbstractView::model_did_update(flags); - if (!model() || (flags & GUI::Model::InvalidateAllIndexes)) { + if (!model() || (flags & GUI::Model::InvalidateAllIndices)) { m_item_data_cache.clear(); AbstractView::clear_selection(); m_selected_count_cache = 0; diff --git a/Userland/Libraries/LibGUI/Model.h b/Userland/Libraries/LibGUI/Model.h index a34256f3e6..8a314c4563 100644 --- a/Userland/Libraries/LibGUI/Model.h +++ b/Userland/Libraries/LibGUI/Model.h @@ -37,8 +37,8 @@ public: class Model : public RefCounted<Model> { public: enum UpdateFlag { - DontInvalidateIndexes = 0, - InvalidateAllIndexes = 1 << 0, + DontInvalidateIndices = 0, + InvalidateAllIndices = 1 << 0, }; enum MatchesFlag { @@ -88,7 +88,7 @@ protected: Model(); void for_each_view(Function<void(AbstractView&)>); - void did_update(unsigned flags = UpdateFlag::InvalidateAllIndexes); + void did_update(unsigned flags = UpdateFlag::InvalidateAllIndices); static bool string_matches(const StringView& str, const StringView& needle, unsigned flags) { diff --git a/Userland/Libraries/LibGUI/ModelSelection.cpp b/Userland/Libraries/LibGUI/ModelSelection.cpp index c4d3aa5c60..12cd9191f4 100644 --- a/Userland/Libraries/LibGUI/ModelSelection.cpp +++ b/Userland/Libraries/LibGUI/ModelSelection.cpp @@ -14,13 +14,13 @@ namespace GUI { void ModelSelection::remove_matching(Function<bool(const ModelIndex&)> filter) { Vector<ModelIndex> to_remove; - for (auto& index : m_indexes) { + for (auto& index : m_indices) { if (filter(index)) to_remove.append(index); } if (!to_remove.is_empty()) { for (auto& index : to_remove) - m_indexes.remove(index); + m_indices.remove(index); notify_selection_changed(); } } @@ -28,19 +28,19 @@ void ModelSelection::remove_matching(Function<bool(const ModelIndex&)> filter) void ModelSelection::set(const ModelIndex& index) { VERIFY(index.is_valid()); - if (m_indexes.size() == 1 && m_indexes.contains(index)) + if (m_indices.size() == 1 && m_indices.contains(index)) return; - m_indexes.clear(); - m_indexes.set(index); + m_indices.clear(); + m_indices.set(index); notify_selection_changed(); } void ModelSelection::add(const ModelIndex& index) { VERIFY(index.is_valid()); - if (m_indexes.contains(index)) + if (m_indices.contains(index)) return; - m_indexes.set(index); + m_indices.set(index); notify_selection_changed(); } @@ -59,28 +59,28 @@ void ModelSelection::add_all(const Vector<ModelIndex>& indices) void ModelSelection::toggle(const ModelIndex& index) { VERIFY(index.is_valid()); - if (m_indexes.contains(index)) - m_indexes.remove(index); + if (m_indices.contains(index)) + m_indices.remove(index); else - m_indexes.set(index); + m_indices.set(index); notify_selection_changed(); } bool ModelSelection::remove(const ModelIndex& index) { VERIFY(index.is_valid()); - if (!m_indexes.contains(index)) + if (!m_indices.contains(index)) return false; - m_indexes.remove(index); + m_indices.remove(index); notify_selection_changed(); return true; } void ModelSelection::clear() { - if (m_indexes.is_empty()) + if (m_indices.is_empty()) return; - m_indexes.clear(); + m_indices.clear(); notify_selection_changed(); } diff --git a/Userland/Libraries/LibGUI/ModelSelection.h b/Userland/Libraries/LibGUI/ModelSelection.h index 86999930a7..8b6ed04710 100644 --- a/Userland/Libraries/LibGUI/ModelSelection.h +++ b/Userland/Libraries/LibGUI/ModelSelection.h @@ -25,12 +25,12 @@ public: { } - int size() const { return m_indexes.size(); } - bool is_empty() const { return m_indexes.is_empty(); } - bool contains(const ModelIndex& index) const { return m_indexes.contains(index); } + int size() const { return m_indices.size(); } + bool is_empty() const { return m_indices.is_empty(); } + bool contains(const ModelIndex& index) const { return m_indices.contains(index); } bool contains_row(int row) const { - for (auto& index : m_indexes) { + for (auto& index : m_indices) { if (index.row() == row) return true; } @@ -47,33 +47,33 @@ public: template<typename Callback> void for_each_index(Callback callback) { - for (auto& index : indexes()) + for (auto& index : indices()) callback(index); } template<typename Callback> void for_each_index(Callback callback) const { - for (auto& index : indexes()) + for (auto& index : indices()) callback(index); } - Vector<ModelIndex> indexes() const + Vector<ModelIndex> indices() const { - Vector<ModelIndex> selected_indexes; + Vector<ModelIndex> selected_indices; - for (auto& index : m_indexes) - selected_indexes.append(index); + for (auto& index : m_indices) + selected_indices.append(index); - return selected_indexes; + return selected_indices; } // FIXME: This doesn't guarantee that what you get is the lowest or "first" index selected.. ModelIndex first() const { - if (m_indexes.is_empty()) + if (m_indices.is_empty()) return {}; - return *m_indexes.begin(); + return *m_indices.begin(); } void remove_matching(Function<bool(const ModelIndex&)>); @@ -94,7 +94,7 @@ private: void notify_selection_changed(); AbstractView& m_view; - HashTable<ModelIndex> m_indexes; + HashTable<ModelIndex> m_indices; bool m_disable_notify { false }; bool m_notify_pending { false }; }; diff --git a/Userland/Libraries/LibGUI/SortingProxyModel.cpp b/Userland/Libraries/LibGUI/SortingProxyModel.cpp index f1feae9b72..7ae72e907e 100644 --- a/Userland/Libraries/LibGUI/SortingProxyModel.cpp +++ b/Userland/Libraries/LibGUI/SortingProxyModel.cpp @@ -24,7 +24,7 @@ SortingProxyModel::~SortingProxyModel() void SortingProxyModel::invalidate(unsigned int flags) { - if (flags == UpdateFlag::DontInvalidateIndexes) { + if (flags == UpdateFlag::DontInvalidateIndices) { sort(m_last_key_column, m_last_sort_order); } else { m_mappings.clear(); @@ -201,20 +201,20 @@ void SortingProxyModel::sort_mapping(Mapping& mapping, int column, SortOrder sor // Update the view's selection. view.selection().change_from_model({}, [&](ModelSelection& selection) { - Vector<ModelIndex> selected_indexes_in_source; - Vector<ModelIndex> stale_indexes_in_selection; + Vector<ModelIndex> selected_indices_in_source; + Vector<ModelIndex> stale_indices_in_selection; selection.for_each_index([&](const ModelIndex& index) { if (index.parent() == mapping.source_parent) { - stale_indexes_in_selection.append(index); - selected_indexes_in_source.append(source().index(old_source_rows[index.row()], index.column(), mapping.source_parent)); + stale_indices_in_selection.append(index); + selected_indices_in_source.append(source().index(old_source_rows[index.row()], index.column(), mapping.source_parent)); } }); - for (auto& index : stale_indexes_in_selection) { + for (auto& index : stale_indices_in_selection) { selection.remove(index); } - for (auto& index : selected_indexes_in_source) { + for (auto& index : selected_indices_in_source) { for (size_t i = 0; i < mapping.source_rows.size(); ++i) { if (mapping.source_rows[i] == index.row()) { auto new_source_index = this->index(i, index.column(), mapping.source_parent); @@ -237,7 +237,7 @@ void SortingProxyModel::sort(int column, SortOrder sort_order) m_last_key_column = column; m_last_sort_order = sort_order; - did_update(UpdateFlag::DontInvalidateIndexes); + did_update(UpdateFlag::DontInvalidateIndices); } SortingProxyModel::InternalMapIterator SortingProxyModel::build_mapping(const ModelIndex& source_parent) @@ -287,10 +287,10 @@ bool SortingProxyModel::is_searchable() const Vector<ModelIndex, 1> SortingProxyModel::matches(const StringView& searching, unsigned flags, const ModelIndex& proxy_index) { - auto found_indexes = source().matches(searching, flags, map_to_source(proxy_index)); - for (size_t i = 0; i < found_indexes.size(); i++) - found_indexes[i] = map_to_proxy(found_indexes[i]); - return found_indexes; + auto found_indices = source().matches(searching, flags, map_to_source(proxy_index)); + for (size_t i = 0; i < found_indices.size(); i++) + found_indices[i] = map_to_proxy(found_indices[i]); + return found_indices; } } diff --git a/Userland/Libraries/LibGUI/SortingProxyModel.h b/Userland/Libraries/LibGUI/SortingProxyModel.h index 57da81998f..22ce2935a4 100644 --- a/Userland/Libraries/LibGUI/SortingProxyModel.h +++ b/Userland/Libraries/LibGUI/SortingProxyModel.h @@ -46,7 +46,7 @@ public: private: explicit SortingProxyModel(NonnullRefPtr<Model> source); - // NOTE: The internal_data() of indexes points to the corresponding Mapping object for that index. + // NOTE: The internal_data() of indices points to the corresponding Mapping object for that index. struct Mapping { Vector<int> source_rows; Vector<int> proxy_rows; @@ -63,7 +63,7 @@ private: Model& source() { return *m_source; } const Model& source() const { return *m_source; } - void invalidate(unsigned flags = Model::UpdateFlag::DontInvalidateIndexes); + void invalidate(unsigned flags = Model::UpdateFlag::DontInvalidateIndices); InternalMapIterator build_mapping(const ModelIndex& proxy_index); NonnullRefPtr<Model> m_source; diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp index 28693cac94..2e866ffb8b 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/PNGLoader.cpp @@ -430,10 +430,10 @@ NEVER_INLINE FLATTEN static bool unfilter(PNGLoadingContext& context) auto pixels_per_byte = 8 / context.bit_depth; auto mask = (1 << context.bit_depth) - 1; for (int y = 0; y < context.height; ++y) { - auto* palette_indexes = context.scanlines[y].data.data(); + auto* palette_indices = context.scanlines[y].data.data(); for (int i = 0; i < context.width; ++i) { auto bit_offset = (8 - context.bit_depth) - (context.bit_depth * (i % pixels_per_byte)); - auto palette_index = (palette_indexes[i / pixels_per_byte] >> bit_offset) & mask; + auto palette_index = (palette_indices[i / pixels_per_byte] >> bit_offset) & mask; auto& pixel = (Pixel&)context.bitmap->scanline(y)[i]; if ((size_t)palette_index >= context.palette_data.size()) return false; diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduce.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduce.js index 9b984fea03..5f423d7fa5 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduce.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduce.js @@ -79,21 +79,21 @@ describe("normal behavior", () => { }, 100); expect(result).toBe(121); - var indexes = []; + var indices = []; result = ["foo", 1, true].reduce((a, v, i) => { - indexes.push(i); + indices.push(i); }); expect(result).toBeUndefined(); - expect(indexes.length).toBe(2); - expect(indexes[0]).toBe(1); - expect(indexes[1]).toBe(2); + expect(indices.length).toBe(2); + expect(indices[0]).toBe(1); + expect(indices[1]).toBe(2); - indexes = []; + indices = []; result = ["foo", 1, true].reduce((a, v, i) => { - indexes.push(i); + indices.push(i); }, "foo"); expect(result).toBeUndefined(); - expect(indexes).toEqual([0, 1, 2]); + expect(indices).toEqual([0, 1, 2]); var mutable = { prop: 0 }; result = ["foo", 1, true].reduce((a, v) => { diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduceRight.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduceRight.js index 3d718a0446..394335f1c3 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduceRight.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduceRight.js @@ -84,21 +84,21 @@ describe("normal behavior", () => { }, 100); expect(result).toBe("100123456"); - var indexes = []; + var indices = []; result = ["foo", 1, true].reduceRight((a, v, i) => { - indexes.push(i); + indices.push(i); }); expect(result).toBeUndefined(); - expect(indexes.length).toBe(2); - expect(indexes[0]).toBe(1); - expect(indexes[1]).toBe(0); + expect(indices.length).toBe(2); + expect(indices[0]).toBe(1); + expect(indices[1]).toBe(0); - indexes = []; + indices = []; result = ["foo", 1, true].reduceRight((a, v, i) => { - indexes.push(i); + indices.push(i); }, "foo"); expect(result).toBeUndefined(); - expect(indexes).toEqual([2, 1, 0]); + expect(indices).toEqual([2, 1, 0]); var mutable = { prop: 0 }; result = ["foo", 1, true].reduceRight((a, v) => { |