Cleanup: Pass Span by value

Also pass Span instead of `const Array &`
and use parantheses for BLI includes.
This commit is contained in:
Hans Goudey
2024-02-27 23:09:54 -05:00
parent 5c5089d651
commit d338261c55
14 changed files with 26 additions and 25 deletions

View File

@@ -670,7 +670,7 @@ struct Fan {
#endif
static bool is_path_valid(const Span<FanSegment *> &path,
static bool is_path_valid(const Span<FanSegment *> path,
const MeshData &mesh_data,
const int from_vertex,
const int to_vertex)

View File

@@ -102,7 +102,7 @@ static std::ostream &operator<<(std::ostream &os, const Edge &e)
return os;
}
static std::ostream &operator<<(std::ostream &os, const Span<int> &a)
static std::ostream &operator<<(std::ostream &os, const Span<int> a)
{
for (int i : a.index_range()) {
os << a[i];
@@ -1908,7 +1908,7 @@ struct ComponentContainer {
*/
static Vector<ComponentContainer> find_component_containers(int comp,
const Span<Vector<int>> components,
const Array<int> &ambient_cell,
const Span<int> ambient_cell,
const IMesh &tm,
const PatchesInfo &pinfo,
const TriMeshTopology &tmtopo,

View File

@@ -2331,7 +2331,7 @@ class TriOverlaps {
public:
TriOverlaps(const IMesh &tm,
const Array<BoundingBox> &tri_bb,
const Span<BoundingBox> tri_bb,
int nshapes,
std::function<int(int)> shape_fn,
bool use_self)
@@ -2642,7 +2642,7 @@ static void calc_subdivided_non_cluster_tris(Array<IMesh> &r_tri_subdivided,
static void calc_cluster_tris(Array<IMesh> &tri_subdivided,
const IMesh &tm,
const CoplanarClusterInfo &clinfo,
const Array<CDT_data> &cluster_subdivided,
const Span<CDT_data> cluster_subdivided,
IMeshArena *arena)
{
for (int c : clinfo.index_range()) {

View File

@@ -95,7 +95,7 @@ template<typename T> CDT_input<T> fill_input_from_string(const char *spec)
/* Find an original index in a table mapping new to original.
* Return -1 if not found.
*/
static int get_orig_index(const Array<Vector<int>> &out_to_orig, int orig_index)
static int get_orig_index(const Span<Vector<int>> out_to_orig, int orig_index)
{
int n = int(out_to_orig.size());
for (int i = 0; i < n; ++i) {
@@ -264,9 +264,9 @@ static bool draw_append = false; /* Will be set to true after first call. */
template<typename T>
void graph_draw(const std::string &label,
const Array<VecBase<T, 2>> &verts,
const Array<std::pair<int, int>> &edges,
const Array<Vector<int>> &faces)
const Span<VecBase<T, 2>> verts,
const Span<std::pair<int, int>> edges,
const Span<Vector<int>> faces)
{
/* Would like to use BKE_tempdir_base() here, but that brings in dependence on kernel library.
* This is just for developer debugging anyway, and should never be called in production Blender.

View File

@@ -462,7 +462,7 @@ class StorageVectorBuffer : public StorageArrayBuffer<T, len, false> {
new (ptr) T(std::forward<ForwardT>(value)...);
}
void extend(const Span<T> &values)
void extend(const Span<T> values)
{
/* TODO(fclem): Optimize to a single memcpy. */
for (auto v : values) {

View File

@@ -82,7 +82,7 @@ class StepDrawingGeometryBase {
* Mismatch in drawing types can happen when some drawings have been deleted between the undo
* step storage, and the current state of the GreasePencil data.
*/
void decode_valid_drawingtype_at_index_ensure(MutableSpan<GreasePencilDrawingBase *> &drawings,
void decode_valid_drawingtype_at_index_ensure(MutableSpan<GreasePencilDrawingBase *> drawings,
const GreasePencilDrawingType drawing_type) const
{
/* TODO: Maybe that code should rather be part of GreasePencil:: API, together with

View File

@@ -448,7 +448,7 @@ static void connect_node_to_surface_output(const Span<bNodeTreePath *> treepath,
/* Connect the nodes to some aov nodes located in the first nodetree from `treepath`. Last element
* of `treepath` should be the path to the nodes nodetree. */
static void connect_nodes_to_aovs(const Span<bNodeTreePath *> treepath,
const Span<NodeSocketPair> &nodesocket_span)
const Span<NodeSocketPair> nodesocket_span)
{
if (nodesocket_span.is_empty()) {
return;

View File

@@ -1998,7 +1998,7 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
* Find the optimal scale to pack islands into the unit square.
* returns largest scale that will pack `islands` into the unit square.
*/
static float pack_islands_margin_fraction(const Span<PackIsland *> &islands,
static float pack_islands_margin_fraction(const Span<PackIsland *> islands,
const float margin_fraction,
const bool rescale_margin,
const UVPackIsland_Params &params)
@@ -2112,7 +2112,7 @@ static float pack_islands_margin_fraction(const Span<PackIsland *> &islands,
return scale_low;
}
static float calc_margin_from_aabb_length_sum(const Span<PackIsland *> &island_vector,
static float calc_margin_from_aabb_length_sum(const Span<PackIsland *> island_vector,
const UVPackIsland_Params &params)
{
/* Logic matches previous behavior from #geometry::uv_parametrizer_pack.
@@ -2201,7 +2201,7 @@ class OverlapMerger {
return result;
}
static float pack_islands_overlap(const Span<PackIsland *> &islands,
static float pack_islands_overlap(const Span<PackIsland *> islands,
const UVPackIsland_Params &params)
{
@@ -2261,7 +2261,7 @@ class OverlapMerger {
}
};
static void finalize_geometry(const Span<PackIsland *> &islands, const UVPackIsland_Params &params)
static void finalize_geometry(const Span<PackIsland *> islands, const UVPackIsland_Params &params)
{
MemArena *arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
Heap *heap = BLI_heap_new();

View File

@@ -35,7 +35,7 @@
namespace blender::io::ply {
/* If line starts with keyword, returns true and drops it from the line. */
static bool parse_keyword(Span<char> &str, StringRef keyword)
static bool parse_keyword(Span<char> str, StringRef keyword)
{
const size_t keyword_len = keyword.size();
if (str.size() < keyword_len) {
@@ -48,7 +48,7 @@ static bool parse_keyword(Span<char> &str, StringRef keyword)
return true;
}
static Span<char> parse_word(Span<char> &str)
static Span<char> parse_word(Span<char> str)
{
size_t len = 0;
while (len < str.size() && str[len] > ' ') {
@@ -59,7 +59,7 @@ static Span<char> parse_word(Span<char> &str)
return word;
}
static void skip_space(Span<char> &str)
static void skip_space(Span<char> str)
{
while (!str.is_empty() && str[0] <= ' ') {
str = str.drop_front(1);

View File

@@ -144,7 +144,7 @@ static void deform_drawing(const GreasePencilNoiseModifierData &mmd,
return vertex_weight * BKE_curvemapping_evaluateF(mmd.influence.custom_curve, 0, value);
};
auto get_noise = [](const Array<float> &noise_table, const float value) {
auto get_noise = [](const Span<float> noise_table, const float value) {
return math::interpolate(noise_table[int(math::ceil(value))],
noise_table[int(math::floor(value))],
math::fract(value));

View File

@@ -921,7 +921,7 @@ struct BakeFrameIndices {
};
static BakeFrameIndices get_bake_frame_indices(
const Span<std::unique_ptr<bake::FrameCache>> &frame_caches, const SubFrame frame)
const Span<std::unique_ptr<bake::FrameCache>> frame_caches, const SubFrame frame)
{
BakeFrameIndices frame_indices;
if (!frame_caches.is_empty()) {

View File

@@ -4,7 +4,7 @@
#pragma once
#include <BLI_vector_set.hh>
#include "BLI_vector_set.hh"
/** \file
* \ingroup sequencer

View File

@@ -230,7 +230,8 @@ void seq_time_effect_range_set(const Scene *scene, Sequence *seq)
seq->len = seq->enddisp - seq->startdisp;
}
void seq_time_update_effects_strip_range(const Scene *scene, blender::Span<Sequence *> &effects)
void seq_time_update_effects_strip_range(const Scene *scene,
const blender::Span<Sequence *> effects)
{
/* First pass: Update length of immediate effects. */
for (Sequence *seq : effects) {

View File

@@ -4,7 +4,7 @@
#pragma once
#include <BLI_span.hh>
#include "BLI_span.hh"
/** \file
* \ingroup sequencer
@@ -40,7 +40,7 @@ void seq_time_effect_range_set(const Scene *scene, Sequence *seq);
/**
* Update strip `startdisp` and `enddisp` (n-input effects have no length to calculate these).
*/
void seq_time_update_effects_strip_range(const Scene *scene, blender::Span<Sequence *> &effects);
void seq_time_update_effects_strip_range(const Scene *scene, blender::Span<Sequence *> effects);
void seq_time_translate_handles(const Scene *scene, Sequence *seq, const int offset);
float seq_time_media_playback_rate_factor_get(const Scene *scene, const Sequence *seq);
int seq_time_strip_original_content_length_get(const Scene *scene, const Sequence *seq);