Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-03-25 04:04:20 +0300
committerCampbell Barton <campbell@blender.org>2022-03-25 04:04:20 +0300
commit4d46fac65d9946382c4be5b3842660e77468f00b (patch)
treec2910a4ca0b2d345007bf853d6484a1b9e53e4e1 /source/blender/blenlib
parentc594cfbe50497fdc365b3f327b643de507cda02f (diff)
Cleanup: use count or num instead of nbr
Follow conventions from T85728.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_statistics.h8
-rw-r--r--source/blender/blenlib/BLI_math_vector.h7
-rw-r--r--source/blender/blenlib/intern/BLI_filelist.c16
-rw-r--r--source/blender/blenlib/intern/fileops.c6
-rw-r--r--source/blender/blenlib/intern/math_statistics.c24
-rw-r--r--source/blender/blenlib/intern/math_vector.c13
-rw-r--r--source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc62
-rw-r--r--source/blender/blenlib/tests/performance/BLI_task_performance_test.cc6
8 files changed, 74 insertions, 68 deletions
diff --git a/source/blender/blenlib/BLI_math_statistics.h b/source/blender/blenlib/BLI_math_statistics.h
index d33d4be360a..e6604eafd3d 100644
--- a/source/blender/blenlib/BLI_math_statistics.h
+++ b/source/blender/blenlib/BLI_math_statistics.h
@@ -28,7 +28,7 @@ extern "C" {
*
* \param n: the dimension of the vectors (and hence, of the covariance matrix to compute).
* \param cos_vn: the nD points to compute covariance from.
- * \param nbr_cos_vn: the number of nD coordinates in cos_vn.
+ * \param cos_vn_num: the number of nD coordinates in cos_vn.
* \param center: the center (or mean point) of cos_vn. If NULL,
* it is assumed cos_vn is already centered.
* \param use_sample_correction: whether to apply sample correction
@@ -37,7 +37,7 @@ extern "C" {
*/
void BLI_covariance_m_vn_ex(int n,
const float *cos_vn,
- int nbr_cos_vn,
+ int cos_vn_num,
const float *center,
bool use_sample_correction,
float *r_covmat);
@@ -45,12 +45,12 @@ void BLI_covariance_m_vn_ex(int n,
* \brief Compute the covariance matrix of given set of 3D coordinates.
*
* \param cos_v3: the 3D points to compute covariance from.
- * \param nbr_cos_v3: the number of 3D coordinates in cos_v3.
+ * \param cos_v3_num: the number of 3D coordinates in cos_v3.
* \return r_covmat the computed covariance matrix.
* \return r_center the computed center (mean) of 3D points (may be NULL).
*/
void BLI_covariance_m3_v3n(const float (*cos_v3)[3],
- int nbr_cos_v3,
+ int cos_vn_num,
bool use_sample_correction,
float r_covmat[3][3],
float r_center[3]);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 4689072bcce..f3283371a3c 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -389,7 +389,7 @@ void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float
void mid_v2_v2v2v2(float v[2], const float v1[2], const float v2[2], const float v3[2]);
void mid_v3_v3v3v3v3(
float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
-void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], unsigned int nbr);
+void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], unsigned int vec_arr_num);
/**
* Specialized function for calculating normals.
@@ -660,7 +660,10 @@ void minmax_v4v4_v4(float min[4], float max[4], const float vec[4]);
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]);
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2]);
-void minmax_v3v3_v3_array(float r_min[3], float r_max[3], const float (*vec_arr)[3], int nbr);
+void minmax_v3v3_v3_array(float r_min[3],
+ float r_max[3],
+ const float (*vec_arr)[3],
+ int var_arr_num);
/** ensure \a v1 is \a dist from \a v2 */
void dist_ensure_v3_v3fl(float v1[3], const float v2[3], float dist);
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 9f1f8fe0448..76fc5b6342a 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -97,8 +97,8 @@ static int bli_compare(struct direntry *entry1, struct direntry *entry2)
}
struct BuildDirCtx {
- struct direntry *files; /* array[nrfiles] */
- int nrfiles;
+ struct direntry *files; /* array[files_num] */
+ int files_num;
};
/**
@@ -154,7 +154,7 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
if (newnum) {
if (dir_ctx->files) {
void *const tmp = MEM_reallocN(dir_ctx->files,
- (dir_ctx->nrfiles + newnum) * sizeof(struct direntry));
+ (dir_ctx->files_num + newnum) * sizeof(struct direntry));
if (tmp) {
dir_ctx->files = (struct direntry *)tmp;
}
@@ -171,7 +171,7 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
if (dir_ctx->files) {
struct dirlink *dlink = (struct dirlink *)dirbase.first;
- struct direntry *file = &dir_ctx->files[dir_ctx->nrfiles];
+ struct direntry *file = &dir_ctx->files[dir_ctx->files_num];
while (dlink) {
char fullname[PATH_MAX];
memset(file, 0, sizeof(struct direntry));
@@ -186,7 +186,7 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
* does not support stat on '\\SERVER\foo\..', sigh... */
file->type |= S_IFDIR;
}
- dir_ctx->nrfiles++;
+ dir_ctx->files_num++;
file++;
dlink = dlink->next;
}
@@ -199,7 +199,7 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
BLI_freelist(&dirbase);
if (dir_ctx->files) {
qsort(dir_ctx->files,
- dir_ctx->nrfiles,
+ dir_ctx->files_num,
sizeof(struct direntry),
(int (*)(const void *, const void *))bli_compare);
}
@@ -219,7 +219,7 @@ unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_
{
struct BuildDirCtx dir_ctx;
- dir_ctx.nrfiles = 0;
+ dir_ctx.files_num = 0;
dir_ctx.files = NULL;
bli_builddir(&dir_ctx, dirname);
@@ -233,7 +233,7 @@ unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_
*r_filelist = MEM_mallocN(sizeof(**r_filelist), __func__);
}
- return dir_ctx.nrfiles;
+ return dir_ctx.files_num;
}
void BLI_filelist_entry_size_to_string(const struct stat *st,
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 27f8f1d4bc8..26a0479f445 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -382,9 +382,9 @@ static bool delete_recursive(const char *dir)
{
struct direntry *filelist, *fl;
bool err = false;
- uint nbr, i;
+ uint filelist_num, i;
- i = nbr = BLI_filelist_dir_contents(dir, &filelist);
+ i = filelist_num = BLI_filelist_dir_contents(dir, &filelist);
fl = filelist;
while (i--) {
const char *file = BLI_path_basename(fl->path);
@@ -415,7 +415,7 @@ static bool delete_recursive(const char *dir)
err = true;
}
- BLI_filelist_free(filelist, nbr);
+ BLI_filelist_free(filelist, filelist_num);
return err;
}
diff --git a/source/blender/blenlib/intern/math_statistics.c b/source/blender/blenlib/intern/math_statistics.c
index 14baca891c0..53fbc16f3fc 100644
--- a/source/blender/blenlib/intern/math_statistics.c
+++ b/source/blender/blenlib/intern/math_statistics.c
@@ -21,7 +21,7 @@ typedef struct CovarianceData {
float *r_covmat;
float covfac;
int n;
- int nbr_cos_vn;
+ int cos_vn_num;
} CovarianceData;
static void covariance_m_vn_ex_task_cb(void *__restrict userdata,
@@ -33,7 +33,7 @@ static void covariance_m_vn_ex_task_cb(void *__restrict userdata,
const float *center = data->center;
float *r_covmat = data->r_covmat;
const int n = data->n;
- const int nbr_cos_vn = data->nbr_cos_vn;
+ const int cos_vn_num = data->cos_vn_num;
int k;
@@ -55,12 +55,12 @@ static void covariance_m_vn_ex_task_cb(void *__restrict userdata,
}
if (center) {
- for (k = 0; k < nbr_cos_vn; k++) {
+ for (k = 0; k < cos_vn_num; k++) {
r_covmat[a] += (cos_vn[k * n + i] - center[i]) * (cos_vn[k * n + j] - center[j]);
}
}
else {
- for (k = 0; k < nbr_cos_vn; k++) {
+ for (k = 0; k < cos_vn_num; k++) {
r_covmat[a] += cos_vn[k * n + i] * cos_vn[k * n + j];
}
}
@@ -73,7 +73,7 @@ static void covariance_m_vn_ex_task_cb(void *__restrict userdata,
void BLI_covariance_m_vn_ex(const int n,
const float *cos_vn,
- const int nbr_cos_vn,
+ const int cos_vn_num,
const float *center,
const bool use_sample_correction,
float *r_covmat)
@@ -81,7 +81,7 @@ void BLI_covariance_m_vn_ex(const int n,
/* Note about that division: see https://en.wikipedia.org/wiki/Bessel%27s_correction.
* In a nutshell, it must be 1 / (n - 1) for 'sample data', and 1 / n for 'population data'...
*/
- const float covfac = 1.0f / (float)(use_sample_correction ? nbr_cos_vn - 1 : nbr_cos_vn);
+ const float covfac = 1.0f / (float)(use_sample_correction ? cos_vn_num - 1 : cos_vn_num);
memset(r_covmat, 0, sizeof(*r_covmat) * (size_t)(n * n));
@@ -91,27 +91,27 @@ void BLI_covariance_m_vn_ex(const int n,
.r_covmat = r_covmat,
.covfac = covfac,
.n = n,
- .nbr_cos_vn = nbr_cos_vn,
+ .cos_vn_num = cos_vn_num,
};
TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
- settings.use_threading = ((nbr_cos_vn * n * n) >= 10000);
+ settings.use_threading = ((cos_vn_num * n * n) >= 10000);
BLI_task_parallel_range(0, n * n, &data, covariance_m_vn_ex_task_cb, &settings);
}
void BLI_covariance_m3_v3n(const float (*cos_v3)[3],
- const int nbr_cos_v3,
+ const int cos_v3_num,
const bool use_sample_correction,
float r_covmat[3][3],
float r_center[3])
{
float center[3];
- const float mean_fac = 1.0f / (float)nbr_cos_v3;
+ const float mean_fac = 1.0f / (float)cos_v3_num;
int i;
zero_v3(center);
- for (i = 0; i < nbr_cos_v3; i++) {
+ for (i = 0; i < cos_v3_num; i++) {
/* Applying mean_fac here rather than once at the end reduce compute errors... */
madd_v3_v3fl(center, cos_v3[i], mean_fac);
}
@@ -121,5 +121,5 @@ void BLI_covariance_m3_v3n(const float (*cos_v3)[3],
}
BLI_covariance_m_vn_ex(
- 3, (const float *)cos_v3, nbr_cos_v3, center, use_sample_correction, (float *)r_covmat);
+ 3, (const float *)cos_v3, cos_v3_num, center, use_sample_correction, (float *)r_covmat);
}
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index da6a6dff16f..5dcdabaf760 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -268,12 +268,12 @@ void mid_v3_v3v3v3v3(
v[2] = (v1[2] + v2[2] + v3[2] + v4[2]) / 4.0f;
}
-void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], const uint nbr)
+void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], const uint vec_arr_num)
{
- const float factor = 1.0f / (float)nbr;
+ const float factor = 1.0f / (float)vec_arr_num;
zero_v3(r);
- for (uint i = 0; i < nbr; i++) {
+ for (uint i = 0; i < vec_arr_num; i++) {
madd_v3_v3fl(r, vec_arr[i], factor);
}
}
@@ -904,9 +904,12 @@ void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
}
}
-void minmax_v3v3_v3_array(float r_min[3], float r_max[3], const float (*vec_arr)[3], int nbr)
+void minmax_v3v3_v3_array(float r_min[3],
+ float r_max[3],
+ const float (*vec_arr)[3],
+ int var_arr_num)
{
- while (nbr--) {
+ while (var_arr_num--) {
minmax_v3v3_v3(r_min, r_max, *vec_arr++);
}
}
diff --git a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
index eae90f130cd..0ff488202c2 100644
--- a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
@@ -177,17 +177,17 @@ TEST(ghash, TextMurmur2a)
/* Int: uniform 100M first integers. */
-static void int_ghash_tests(GHash *ghash, const char *id, const unsigned int nbr)
+static void int_ghash_tests(GHash *ghash, const char *id, const unsigned int count)
{
printf("\n========== STARTING %s ==========\n", id);
{
- unsigned int i = nbr;
+ unsigned int i = count;
TIMEIT_START(int_insert);
#ifdef GHASH_RESERVE
- BLI_ghash_reserve(ghash, nbr);
+ BLI_ghash_reserve(ghash, count);
#endif
while (i--) {
@@ -200,7 +200,7 @@ static void int_ghash_tests(GHash *ghash, const char *id, const unsigned int nbr
PRINTF_GHASH_STATS(ghash);
{
- unsigned int i = nbr;
+ unsigned int i = count;
TIMEIT_START(int_lookup);
@@ -266,17 +266,17 @@ TEST(ghash, IntMurmur2a100000000)
/* Int: random 50M integers. */
-static void randint_ghash_tests(GHash *ghash, const char *id, const unsigned int nbr)
+static void randint_ghash_tests(GHash *ghash, const char *id, const unsigned int count)
{
printf("\n========== STARTING %s ==========\n", id);
- unsigned int *data = (unsigned int *)MEM_mallocN(sizeof(*data) * (size_t)nbr, __func__);
+ unsigned int *data = (unsigned int *)MEM_mallocN(sizeof(*data) * (size_t)count, __func__);
unsigned int *dt;
unsigned int i;
{
RNG *rng = BLI_rng_new(1);
- for (i = nbr, dt = data; i--; dt++) {
+ for (i = count, dt = data; i--; dt++) {
*dt = BLI_rng_get_uint(rng);
}
BLI_rng_free(rng);
@@ -286,10 +286,10 @@ static void randint_ghash_tests(GHash *ghash, const char *id, const unsigned int
TIMEIT_START(int_insert);
#ifdef GHASH_RESERVE
- BLI_ghash_reserve(ghash, nbr);
+ BLI_ghash_reserve(ghash, count);
#endif
- for (i = nbr, dt = data; i--; dt++) {
+ for (i = count, dt = data; i--; dt++) {
BLI_ghash_insert(ghash, POINTER_FROM_UINT(*dt), POINTER_FROM_UINT(*dt));
}
@@ -301,7 +301,7 @@ static void randint_ghash_tests(GHash *ghash, const char *id, const unsigned int
{
TIMEIT_START(int_lookup);
- for (i = nbr, dt = data; i--; dt++) {
+ for (i = count, dt = data; i--; dt++) {
void *v = BLI_ghash_lookup(ghash, POINTER_FROM_UINT(*dt));
EXPECT_EQ(POINTER_AS_UINT(v), *dt);
}
@@ -375,18 +375,18 @@ TEST(ghash, Int4NoHash50000000)
/* Int_v4: 20M of randomly-generated integer vectors. */
-static void int4_ghash_tests(GHash *ghash, const char *id, const unsigned int nbr)
+static void int4_ghash_tests(GHash *ghash, const char *id, const unsigned int count)
{
printf("\n========== STARTING %s ==========\n", id);
- void *data_v = MEM_mallocN(sizeof(unsigned int[4]) * (size_t)nbr, __func__);
+ void *data_v = MEM_mallocN(sizeof(unsigned int[4]) * (size_t)count, __func__);
unsigned int(*data)[4] = (unsigned int(*)[4])data_v;
unsigned int(*dt)[4];
unsigned int i, j;
{
RNG *rng = BLI_rng_new(1);
- for (i = nbr, dt = data; i--; dt++) {
+ for (i = count, dt = data; i--; dt++) {
for (j = 4; j--;) {
(*dt)[j] = BLI_rng_get_uint(rng);
}
@@ -398,10 +398,10 @@ static void int4_ghash_tests(GHash *ghash, const char *id, const unsigned int nb
TIMEIT_START(int_v4_insert);
#ifdef GHASH_RESERVE
- BLI_ghash_reserve(ghash, nbr);
+ BLI_ghash_reserve(ghash, count);
#endif
- for (i = nbr, dt = data; i--; dt++) {
+ for (i = count, dt = data; i--; dt++) {
BLI_ghash_insert(ghash, *dt, POINTER_FROM_UINT(i));
}
@@ -413,7 +413,7 @@ static void int4_ghash_tests(GHash *ghash, const char *id, const unsigned int nb
{
TIMEIT_START(int_v4_lookup);
- for (i = nbr, dt = data; i--; dt++) {
+ for (i = count, dt = data; i--; dt++) {
void *v = BLI_ghash_lookup(ghash, (void *)(*dt));
EXPECT_EQ(POINTER_AS_UINT(v), i);
}
@@ -483,25 +483,25 @@ TEST(ghash, Int2NoHash50000000)
/* MultiSmall: create and manipulate a lot of very small ghash's
* (90% < 10 items, 9% < 100 items, 1% < 1000 items). */
-static void multi_small_ghash_tests_one(GHash *ghash, RNG *rng, const unsigned int nbr)
+static void multi_small_ghash_tests_one(GHash *ghash, RNG *rng, const unsigned int count)
{
- unsigned int *data = (unsigned int *)MEM_mallocN(sizeof(*data) * (size_t)nbr, __func__);
+ unsigned int *data = (unsigned int *)MEM_mallocN(sizeof(*data) * (size_t)count, __func__);
unsigned int *dt;
unsigned int i;
- for (i = nbr, dt = data; i--; dt++) {
+ for (i = count, dt = data; i--; dt++) {
*dt = BLI_rng_get_uint(rng);
}
#ifdef GHASH_RESERVE
- BLI_ghash_reserve(ghash, nbr);
+ BLI_ghash_reserve(ghash, count);
#endif
- for (i = nbr, dt = data; i--; dt++) {
+ for (i = count, dt = data; i--; dt++) {
BLI_ghash_insert(ghash, POINTER_FROM_UINT(*dt), POINTER_FROM_UINT(*dt));
}
- for (i = nbr, dt = data; i--; dt++) {
+ for (i = count, dt = data; i--; dt++) {
void *v = BLI_ghash_lookup(ghash, POINTER_FROM_UINT(*dt));
EXPECT_EQ(POINTER_AS_UINT(v), *dt);
}
@@ -510,7 +510,7 @@ static void multi_small_ghash_tests_one(GHash *ghash, RNG *rng, const unsigned i
MEM_freeN(data);
}
-static void multi_small_ghash_tests(GHash *ghash, const char *id, const unsigned int nbr)
+static void multi_small_ghash_tests(GHash *ghash, const char *id, const unsigned int count)
{
printf("\n========== STARTING %s ==========\n", id);
@@ -518,22 +518,22 @@ static void multi_small_ghash_tests(GHash *ghash, const char *id, const unsigned
TIMEIT_START(multi_small_ghash);
- unsigned int i = nbr;
+ unsigned int i = count;
while (i--) {
- const int nbr = 1 + (BLI_rng_get_int(rng) % TESTCASE_SIZE_SMALL) *
- (!(i % 100) ? 100 : (!(i % 10) ? 10 : 1));
- multi_small_ghash_tests_one(ghash, rng, nbr);
+ const int count = 1 + (BLI_rng_get_int(rng) % TESTCASE_SIZE_SMALL) *
+ (!(i % 100) ? 100 : (!(i % 10) ? 10 : 1));
+ multi_small_ghash_tests_one(ghash, rng, count);
}
TIMEIT_END(multi_small_ghash);
TIMEIT_START(multi_small2_ghash);
- unsigned int i = nbr;
+ unsigned int i = count;
while (i--) {
- const int nbr = 1 + (BLI_rng_get_int(rng) % TESTCASE_SIZE_SMALL) / 2 *
- (!(i % 100) ? 100 : (!(i % 10) ? 10 : 1));
- multi_small_ghash_tests_one(ghash, rng, nbr);
+ const int count = 1 + (BLI_rng_get_int(rng) % TESTCASE_SIZE_SMALL) / 2 *
+ (!(i % 100) ? 100 : (!(i % 10) ? 10 : 1));
+ multi_small_ghash_tests_one(ghash, rng, count);
}
TIMEIT_END(multi_small2_ghash);
diff --git a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
index 33a196569e9..98fafe55d69 100644
--- a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
@@ -135,17 +135,17 @@ static void task_listbase_test_do(ListBase *list,
NUM_RUN_AVERAGED);
}
-static void task_listbase_test(const char *id, const int nbr, const bool use_threads)
+static void task_listbase_test(const char *id, const int count, const bool use_threads)
{
printf("\n========== STARTING %s ==========\n", id);
ListBase list = {nullptr, nullptr};
- LinkData *items_buffer = (LinkData *)MEM_calloc_arrayN(nbr, sizeof(*items_buffer), __func__);
+ LinkData *items_buffer = (LinkData *)MEM_calloc_arrayN(count, sizeof(*items_buffer), __func__);
BLI_threadapi_init();
int num_items = 0;
- for (int i = 0; i < nbr; i++) {
+ for (int i = 0; i < count; i++) {
BLI_addtail(&list, &items_buffer[i]);
num_items++;
}