cleanup: don't pass size_t by reference (it's only 8 bytes)

This commit is contained in:
Eric Wasylishen 2024-11-17 21:26:27 -07:00
parent b8fdbe3d41
commit c755f47c03
8 changed files with 37 additions and 37 deletions

View File

@ -1200,7 +1200,7 @@ static void DecompileEntity(
// decompile the leafs in parallel
compiledBrushes.resize(tasks.size());
tbb::parallel_for(static_cast<size_t>(0), tasks.size(), [&](const size_t &i) {
tbb::parallel_for(static_cast<size_t>(0), tasks.size(), [&](size_t i) {
compiledBrushes[i] = DecompileLeafTaskGeometryOnly(bsp, tasks[i], brush_offset);
});
} else if (bsp->loadversion->game->id == GAME_QUAKE_II && !options.ignoreBrushes) {
@ -1251,7 +1251,7 @@ static void DecompileEntity(
compiledBrushes.resize(brushes.size());
size_t t = brushes.size();
tbb::parallel_for(static_cast<size_t>(0), brushes.size(), [&](const size_t &i) {
tbb::parallel_for(static_cast<size_t>(0), brushes.size(), [&](size_t i) {
compiledBrushes[i] = DecompileBrushTask(bsp, options, brushesVector[i], brush_offset);
t--;
});
@ -1267,7 +1267,7 @@ static void DecompileEntity(
// decompile the leafs in parallel
compiledBrushes.resize(tasks.size());
tbb::parallel_for(static_cast<size_t>(0), tasks.size(), [&](const size_t &i) {
tbb::parallel_for(static_cast<size_t>(0), tasks.size(), [&](size_t i) {
if (options.geometryOnly) {
compiledBrushes[i] = DecompileLeafTaskGeometryOnly(bsp, tasks[i], brush_offset);
} else {
@ -1427,7 +1427,7 @@ std::vector<leaf_visualization_t> VisualizeLeafs(const mbsp_t &bsp, int modelnum
// decompile the leafs in parallel
compiledBrushes.resize(tasks.size());
tbb::parallel_for(static_cast<size_t>(0), tasks.size(), [&](const size_t &i) {
tbb::parallel_for(static_cast<size_t>(0), tasks.size(), [&](size_t i) {
compiledBrushes[i] = DecompileLeafTaskLeafVisualization(&bsp, tasks[i], std::nullopt);
});

View File

@ -226,9 +226,9 @@ public:
constexpr aabb grow(const value_type &size) const { return {mins() - size, maxs() + size}; }
constexpr value_type &operator[](const size_t &index) { return m_corners[index]; }
constexpr value_type &operator[](size_t index) { return m_corners[index]; }
constexpr const value_type &operator[](const size_t &index) const { return m_corners[index]; }
constexpr const value_type &operator[](size_t index) const { return m_corners[index]; }
constexpr value_type centroid() const { return (mins() + maxs()) * 0.5; }

View File

@ -62,7 +62,7 @@ public:
// construct winding with initial size; may allocate
// memory, and sets size, but does not initialize any
// of them.
inline winding_storage_stack_t(const size_t &initial_size)
inline winding_storage_stack_t(size_t initial_size)
: count(initial_size)
{
if (initial_size > N) {
@ -124,7 +124,7 @@ public:
inline size_t size() const { return count; }
inline vec3_type &at(const size_t &index)
inline vec3_type &at(size_t index)
{
#ifdef _DEBUG
if (index >= count)
@ -134,7 +134,7 @@ public:
return array[index];
}
inline const vec3_type &at(const size_t &index) const
inline const vec3_type &at(size_t index) const
{
#ifdef _DEBUG
if (index >= count)
@ -145,10 +145,10 @@ public:
}
// un-bounds-checked
inline vec3_type &operator[](const size_t &index) { return array[index]; }
inline vec3_type &operator[](size_t index) { return array[index]; }
// un-bounds-checked
inline const vec3_type &operator[](const size_t &index) const { return array[index]; }
inline const vec3_type &operator[](size_t index) const { return array[index]; }
using const_iterator = typename array_type::const_iterator;
@ -173,7 +173,7 @@ public:
return (array[count - 1] = vec);
}
inline void resize(const size_t &new_size)
inline void resize(size_t new_size)
{
if (new_size > N) {
throw std::bad_alloc();
@ -204,7 +204,7 @@ public:
// construct winding with initial size; may allocate
// memory, and sets size, but does not initialize any
// of them.
inline winding_storage_heap_t(const size_t &initial_size)
inline winding_storage_heap_t(size_t initial_size)
: values(initial_size)
{
}
@ -252,15 +252,15 @@ public:
inline size_t size() const { return values.size(); }
inline vec3_type &at(const size_t &index) { return values[index]; }
inline vec3_type &at(size_t index) { return values[index]; }
inline const vec3_type &at(const size_t &index) const { return values[index]; }
inline const vec3_type &at(size_t index) const { return values[index]; }
// un-bounds-checked
inline vec3_type &operator[](const size_t &index) { return values[index]; }
inline vec3_type &operator[](size_t index) { return values[index]; }
// un-bounds-checked
inline const vec3_type &operator[](const size_t &index) const { return values[index]; }
inline const vec3_type &operator[](size_t index) const { return values[index]; }
inline const auto begin() const { return values.begin(); }
@ -272,7 +272,7 @@ public:
inline vec3_type &emplace_back(const vec3_type &vec) { return values.emplace_back(vec); }
inline void resize(const size_t &new_size) { values.resize(new_size); }
inline void resize(size_t new_size) { values.resize(new_size); }
inline void reserve(size_t size) { values.reserve(size); }
@ -396,7 +396,7 @@ public:
// construct winding with initial size; may allocate
// memory, and sets size, but does not initialize any
// of them.
inline winding_storage_hybrid_t(const size_t &initial_size)
inline winding_storage_hybrid_t(size_t initial_size)
: count(initial_size)
{
if (count > N) {
@ -491,7 +491,7 @@ public:
inline size_t vector_size() const { return vector.size(); }
inline vec3_type &at(const size_t &index)
inline vec3_type &at(size_t index)
{
#ifdef _DEBUG
if (index >= count)
@ -505,7 +505,7 @@ public:
return array[index];
}
inline const vec3_type &at(const size_t &index) const
inline const vec3_type &at(size_t index) const
{
#ifdef _DEBUG
if (index >= count)
@ -520,7 +520,7 @@ public:
}
// un-bounds-checked
inline vec3_type &operator[](const size_t &index)
inline vec3_type &operator[](size_t index)
{
if (index >= N) {
return vector[index - N];
@ -530,7 +530,7 @@ public:
}
// un-bounds-checked
inline const vec3_type &operator[](const size_t &index) const
inline const vec3_type &operator[](size_t index) const
{
if (index >= N) {
return vector[index - N];
@ -562,7 +562,7 @@ public:
return (array[count - 1] = vec);
}
inline void resize(const size_t &new_size)
inline void resize(size_t new_size)
{
// resize vector if necessary
if (new_size > N) {
@ -595,7 +595,7 @@ public:
// construct winding with initial size; may allocate
// memory, and sets size, but does not initialize any
// of them.
inline winding_base_t(const size_t &initial_size)
inline winding_base_t(size_t initial_size)
: storage(initial_size)
{
}
@ -639,15 +639,15 @@ public:
inline size_t size() const { return storage.size(); }
inline vec3_type &at(const size_t &index) { return storage.at(index); }
inline vec3_type &at(size_t index) { return storage.at(index); }
inline const vec3_type &at(const size_t &index) const { return storage.at(index); }
inline const vec3_type &at(size_t index) const { return storage.at(index); }
// un-bounds-checked
inline vec3_type &operator[](const size_t &index) { return storage[index]; }
inline vec3_type &operator[](size_t index) { return storage[index]; }
// un-bounds-checked
inline const vec3_type &operator[](const size_t &index) const { return storage[index]; }
inline const vec3_type &operator[](size_t index) const { return storage[index]; }
inline const auto begin() const { return storage.begin(); }
@ -665,7 +665,7 @@ public:
inline void push_back(const vec3_type &vec) { storage.emplace_back(vec); }
inline void resize(const size_t &new_size) { storage.resize(new_size); }
inline void resize(size_t new_size) { storage.resize(new_size); }
inline void reserve(size_t size) { storage.reserve(size); }

View File

@ -227,7 +227,7 @@ struct mapdata_t
std::optional<size_t> find_emitted_hash_vector(const qvec3d &vert);
// add vector to hash
void add_hash_vector(const qvec3d &point, const size_t &num);
void add_hash_vector(const qvec3d &point, size_t num);
// hashed edges; generated by EmitEdges
std::map<std::pair<size_t, size_t>, hashedge_t> hashedges;

View File

@ -75,7 +75,7 @@ public:
return *this;
}
constexpr const size_t &size() const { return _size; }
constexpr size_t size() const { return _size; }
// this clears existing bit data!
inline void resize(size_t new_size) { *this = leafbits_t(new_size); }
@ -86,7 +86,7 @@ public:
inline uint32_t *data() { return bits.get(); }
inline const uint32_t *data() const { return bits.get(); }
inline bool operator[](const size_t &index) const { return !!(bits[index >> shift] & nth_bit(index & mask)); }
inline bool operator[](size_t index) const { return !!(bits[index >> shift] & nth_bit(index & mask)); }
struct reference
{
@ -107,5 +107,5 @@ public:
}
};
inline reference operator[](const size_t &index) { return {bits, index >> shift, nth_bit(index & mask)}; }
inline reference operator[](size_t index) { return {bits, index >> shift, nth_bit(index & mask)}; }
};

View File

@ -142,7 +142,7 @@ GetEdge
Returns a global edge number, possibly negative to indicate a backwards edge.
==================
*/
inline int64_t GetEdge(const size_t &v1, const size_t &v2, const face_t *face, emit_faces_stats_t &stats)
inline int64_t GetEdge(size_t v1, size_t v2, const face_t *face, emit_faces_stats_t &stats)
{
if (!face->contents.front.is_valid(qbsp_options.target_game, false))
FError("Face with invalid contents");

View File

@ -161,7 +161,7 @@ std::optional<size_t> mapdata_t::find_emitted_hash_vector(const qvec3d &vert)
}
// add vector to hash
void mapdata_t::add_hash_vector(const qvec3d &point, const size_t &num)
void mapdata_t::add_hash_vector(const qvec3d &point, size_t num)
{
hashverts->hash.emplace(pareto::point<double, 3>({point[0], point[1], point[2]}), num);
}

View File

@ -454,7 +454,7 @@ static std::list<std::vector<size_t>> compress_triangles_into_fans(
{
size_t seed, vert_count;
bool operator()(const size_t &a, const size_t &b) const
bool operator()(size_t a, size_t b) const
{
size_t ka = a < seed ? vert_count + a : a;
size_t kb = b < seed ? vert_count + b : b;