Cleanup: Remove unnecessary includes from C++ data structure headers

The hash tables and vector blenlib headers were pulling many more
headers than they actually need, including the C base math header,
our C string API header, and the StringRef header. All of this
potentially slows down compilation and polutes autocomplete
with unrelated information.

Also remove the `ListBase` constructor for `Vector`. It wasn't used
much, and making it easy to use `ListBase` isn't worth it for the
same reasons mentioned above.

It turns out a lot of files depended on indirect includes of
`BLI_string.h` and `BLI_listbase.h`, so those are fixed here.

Pull Request: https://projects.blender.org/blender/blender/pulls/111801
This commit is contained in:
Hans Goudey
2023-09-01 21:37:11 +02:00
committed by Hans Goudey
parent 9f4b28bba8
commit fa34992def
135 changed files with 237 additions and 71 deletions

View File

@@ -8,6 +8,7 @@
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_string.h"
#include "DNA_armature_types.h"

View File

@@ -8,6 +8,8 @@
#include <memory>
#include "BLI_string.h"
#include "AS_asset_identifier.hh"
#include "AS_asset_library.hh"

View File

@@ -1,8 +1,11 @@
/* SPDX-FileCopyrightText: 2021 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "testing/testing.h"
#include "BLI_string.h"
#include "BKE_cryptomatte.h"
#include "BKE_cryptomatte.hh"
#include "BKE_image.h"

View File

@@ -2,6 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_listbase.h"
#include "BLI_task.hh"
#include "BLI_vector.hh"
@@ -81,7 +82,10 @@ static KnotsMode knots_mode_from_legacy(const short flag)
Curves *curve_legacy_to_curves(const Curve &curve_legacy, const ListBase &nurbs_list)
{
const Vector<const Nurb *> src_curves(nurbs_list);
Vector<const Nurb *> src_curves;
LISTBASE_FOREACH (const Nurb *, item, &nurbs_list) {
src_curves.append(item);
}
if (src_curves.is_empty()) {
return nullptr;
}

View File

@@ -13,6 +13,7 @@
#include "BLI_color.hh"
#include "BLI_listbase.h"
#include "BLI_math_vector_types.hh"
#include "BLI_string.h"
#include "BLI_vector.hh"
#include "DNA_gpencil_legacy_types.h"

View File

@@ -4,6 +4,8 @@
#include "testing/testing.h"
#include "BLI_string.h"
#include "BKE_curves.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_idtype.h"

View File

@@ -4,6 +4,8 @@
#include "testing/testing.h"
#include "BLI_listbase.h"
#include "DNA_ID.h"
#include "BKE_idprop.hh"

View File

@@ -57,6 +57,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "BLI_listbase.h"
#include "BLI_vector.hh"
namespace blender::bke::image::partial_update {

View File

@@ -18,6 +18,7 @@
#include "BLI_map.hh"
#include "BLI_math_base.hh"
#include "BLI_set.hh"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_string_utils.h"

View File

@@ -41,6 +41,7 @@
#include "BLI_listbase.h"
#include "BLI_math_color.h"
#include "BLI_math_vector.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"

View File

@@ -25,6 +25,7 @@
#include "BLI_mesh_boolean.hh"
#include "BLI_mesh_intersect.hh"
#include "BLI_span.hh"
#include "BLI_string.h"
#include "BLI_task.hh"
#include "BLI_virtual_array.hh"

View File

@@ -23,6 +23,7 @@
#include "BLI_memarena.h"
#include "BLI_polyfill_2d.h"
#include "BLI_resource_scope.hh"
#include "BLI_string.h"
#include "BLI_task.hh"
#include "BLI_utildefines.h"

View File

@@ -452,12 +452,10 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source)
/* Make sure active/default color attribute (names) are brought over. */
if (source->active_color_attribute) {
MEM_SAFE_FREE(target->active_color_attribute);
target->active_color_attribute = BLI_strdup(source->active_color_attribute);
BKE_id_attributes_active_color_set(&target->id, source->active_color_attribute);
}
if (source->default_color_attribute) {
MEM_SAFE_FREE(target->default_color_attribute);
target->default_color_attribute = BLI_strdup(source->default_color_attribute);
BKE_id_attributes_default_color_set(&target->id, source->default_color_attribute);
}
free_bvhtree_from_mesh(&bvhtree);

View File

@@ -17,6 +17,7 @@
#include "BLI_math_geom.h"
#include "BLI_math_vector.h"
#include "BLI_string.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"

View File

@@ -1,7 +1,9 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_compiler_compat.h"
#include "BLI_string.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"

View File

@@ -14,9 +14,11 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BLI_math_vector.h"
#include "BLI_task.h"
#include "PIL_time.h"
#include "BKE_global.h"

View File

@@ -4,6 +4,7 @@
#include "BLI_array.hh"
#include "BLI_bit_vector.hh"
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BLI_math_vector.hh"
#include "BLI_task.hh"

View File

@@ -17,6 +17,7 @@
#include "BLI_fileops.hh"
#include "BLI_hash_md5.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_string_utils.h"
#include "MOD_nodes.hh"