mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK+Everywhere: Change int to size_t in JsonObject and JsonArray
This commit is contained in:
parent
66526cbbaf
commit
f45273649f
Notes:
sideshowbarker
2024-07-18 11:21:23 +09:00
Author: https://github.com/MaxWipfli Commit: https://github.com/SerenityOS/serenity/commit/f45273649f3 Pull-request: https://github.com/SerenityOS/serenity/pull/8293 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/awesomekling
9 changed files with 14 additions and 14 deletions
|
@ -48,7 +48,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
int size() const { return m_values.size(); }
|
||||
size_t size() const { return m_values.size(); }
|
||||
bool is_empty() const { return m_values.is_empty(); }
|
||||
|
||||
JsonValue const& at(size_t index) const { return m_values.at(index); }
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
void clear() { m_values.clear(); }
|
||||
void append(JsonValue value) { m_values.append(move(value)); }
|
||||
void set(int index, JsonValue value) { m_values[index] = move(value); }
|
||||
void set(size_t index, JsonValue value) { m_values[index] = move(value); }
|
||||
|
||||
template<typename Builder>
|
||||
typename Builder::OutputType serialized() const;
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
Vector<JsonValue> const& values() const { return m_values; }
|
||||
|
||||
void ensure_capacity(int capacity) { m_values.ensure_capacity(capacity); }
|
||||
void ensure_capacity(size_t capacity) { m_values.ensure_capacity(capacity); }
|
||||
|
||||
private:
|
||||
Vector<JsonValue> m_values;
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
int size() const { return m_members.size(); }
|
||||
size_t size() const { return m_members.size(); }
|
||||
bool is_empty() const { return m_members.is_empty(); }
|
||||
|
||||
JsonValue const& get(String const& key) const
|
||||
|
|
|
@ -90,7 +90,7 @@ bool JsonValue::equals(const JsonValue& other) const
|
|||
|
||||
if (is_array() && other.is_array() && as_array().size() == other.as_array().size()) {
|
||||
bool result = true;
|
||||
for (int i = 0; i < as_array().size(); ++i) {
|
||||
for (size_t i = 0; i < as_array().size(); ++i) {
|
||||
result &= as_array().at(i).equals(other.as_array().at(i));
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -22,7 +22,7 @@ int RemoteObjectPropertyModel::row_count(const GUI::ModelIndex& index) const
|
|||
return value.as_array().size();
|
||||
else if (value.is_object())
|
||||
return value.as_object().size();
|
||||
return 0;
|
||||
return (size_t)0;
|
||||
};
|
||||
|
||||
if (index.is_valid()) {
|
||||
|
|
|
@ -58,7 +58,7 @@ void CommonLocationsProvider::load_from_json(const String& json_path)
|
|||
|
||||
s_common_locations.clear();
|
||||
auto contents = json.value().as_array();
|
||||
for (auto i = 0; i < contents.size(); ++i) {
|
||||
for (size_t i = 0; i < contents.size(); ++i) {
|
||||
auto entry_value = contents.at(i);
|
||||
if (!entry_value.is_object())
|
||||
continue;
|
||||
|
|
|
@ -59,7 +59,7 @@ bool JsonArrayModel::set(int row, Vector<JsonValue>&& values)
|
|||
{
|
||||
VERIFY(values.size() == m_fields.size());
|
||||
|
||||
if (row >= m_array.size())
|
||||
if ((size_t)row >= m_array.size())
|
||||
return false;
|
||||
|
||||
JsonObject obj;
|
||||
|
@ -76,12 +76,12 @@ bool JsonArrayModel::set(int row, Vector<JsonValue>&& values)
|
|||
|
||||
bool JsonArrayModel::remove(int row)
|
||||
{
|
||||
if (row >= m_array.size())
|
||||
if ((size_t)row >= m_array.size())
|
||||
return false;
|
||||
|
||||
JsonArray new_array;
|
||||
for (int i = 0; i < m_array.size(); ++i)
|
||||
if (i != row)
|
||||
for (size_t i = 0; i < m_array.size(); ++i)
|
||||
if (i != (size_t)row)
|
||||
new_array.append(m_array.at(i));
|
||||
|
||||
m_array = new_array;
|
||||
|
|
|
@ -74,7 +74,7 @@ Vector<u32> CharacterMapFile::read_map(const JsonObject& json, const String& nam
|
|||
buffer.resize(CHAR_MAP_SIZE);
|
||||
|
||||
auto map_arr = json.get(name).as_array();
|
||||
for (int i = 0; i < map_arr.size(); i++) {
|
||||
for (size_t i = 0; i < map_arr.size(); i++) {
|
||||
auto key_value = map_arr.at(i).as_string();
|
||||
if (key_value.length() == 0) {
|
||||
buffer[i] = 0;
|
||||
|
|
|
@ -59,7 +59,7 @@ private:
|
|||
static Vector<Quote> parse_all(const JsonArray& array)
|
||||
{
|
||||
Vector<Quote> quotes;
|
||||
for (int i = 0; i < array.size(); ++i) {
|
||||
for (size_t i = 0; i < array.size(); ++i) {
|
||||
Optional<Quote> q = Quote::try_parse(array[i]);
|
||||
if (!q.has_value()) {
|
||||
warnln("WARNING: Could not parse quote #{}!", i);
|
||||
|
|
|
@ -112,7 +112,7 @@ static void print(const String& name, const JsonValue& value, Vector<String>& tr
|
|||
if (value.is_array()) {
|
||||
outln("{}[]{};", color_brace, color_off);
|
||||
trail.append(String::formatted("{}{}{}", color_name, name, color_off));
|
||||
for (int i = 0; i < value.as_array().size(); ++i) {
|
||||
for (size_t i = 0; i < value.as_array().size(); ++i) {
|
||||
auto element_name = String::formatted("{}{}[{}{}{}{}{}]{}", color_off, color_brace, color_off, color_index, i, color_off, color_brace, color_off);
|
||||
print(element_name, value.as_array()[i], trail);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue