Bladeren bron

Help: Use array size instead of sizeof to determine number of sections

This was a relict when the sections were still a help-internal array.
kleines Filmröllchen 2 jaren geleden
bovenliggende
commit
437d3ca0ea
1 gewijzigde bestanden met toevoegingen van 2 en 2 verwijderingen
  1. 2 2
      Userland/Applications/Help/ManualModel.cpp

+ 2 - 2
Userland/Applications/Help/ManualModel.cpp

@@ -123,7 +123,7 @@ GUI::ModelIndex ManualModel::parent_index(const GUI::ModelIndex& index) const
         return {};
 
     if (parent->parent() == nullptr) {
-        for (size_t row = 0; row < sizeof(Manual::sections) / sizeof(Manual::sections[0]); row++)
+        for (size_t row = 0; row < Manual::sections.size(); row++)
             if (Manual::sections[row].ptr() == parent)
                 return create_index(row, 0, parent);
         VERIFY_NOT_REACHED();
@@ -139,7 +139,7 @@ GUI::ModelIndex ManualModel::parent_index(const GUI::ModelIndex& index) const
 int ManualModel::row_count(const GUI::ModelIndex& index) const
 {
     if (!index.is_valid())
-        return sizeof(Manual::sections) / sizeof(Manual::sections[0]);
+        return static_cast<int>(Manual::sections.size());
     auto* node = static_cast<Manual::Node const*>(index.internal_data());
     return node->children().size();
 }