Cleanup: various non-functional changes for C++

This commit is contained in:
Campbell Barton 2024-02-02 10:43:18 +11:00
parent c4a2858975
commit e72c9397f5
7 changed files with 33 additions and 33 deletions

View File

@ -389,7 +389,7 @@ BLI_INLINE bool bchunk_data_compare_unchecked(const BChunk *chunk,
const size_t data_base_len,
const size_t offset)
{
BLI_assert(offset + (size_t)chunk->data_len <= data_base_len);
BLI_assert(offset + size_t(chunk->data_len) <= data_base_len);
UNUSED_VARS_NDEBUG(data_base_len);
return (memcmp(&data_base[offset], chunk->data, chunk->data_len) == 0);
}
@ -399,7 +399,7 @@ static bool bchunk_data_compare(const BChunk *chunk,
const size_t data_base_len,
const size_t offset)
{
if (offset + (size_t)chunk->data_len <= data_base_len) {
if (offset + size_t(chunk->data_len) <= data_base_len) {
return bchunk_data_compare_unchecked(chunk, data_base, data_base_len, offset);
}
return false;
@ -974,7 +974,7 @@ static const BChunkRef *table_lookup(const BArrayInfo *info,
const hash_key *table_hash_array)
{
const hash_key key = table_hash_array[((offset - i_table_start) / info->chunk_stride)];
const uint key_index = (uint)(key % (hash_key)table_len);
const uint key_index = uint(key % (hash_key)table_len);
const BTableRef *tref = table[key_index];
if (tref != nullptr) {
const size_t size_left = data_len - offset;
@ -1041,7 +1041,7 @@ static const BChunkRef *table_lookup(const BArrayInfo *info,
const size_t size_left = data_len - offset;
const hash_key key = hash_data(&data[offset], std::min(data_hash_len, size_left));
const uint key_index = (uint)(key % (hash_key)table_len);
const uint key_index = uint(key % (hash_key)table_len);
for (BTableRef *tref = table[key_index]; tref; tref = tref->next) {
const BChunkRef *cref = tref->cref;
# ifdef USE_HASH_TABLE_KEY_CACHE
@ -1331,7 +1331,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
hash_store_len
#endif
);
const uint key_index = (uint)(key % (hash_key)table_len);
const uint key_index = uint(key % (hash_key)table_len);
BTableRef *tref_prev = table[key_index];
BLI_assert(table_ref_stack_n < chunk_list_reference_remaining_len);
#ifdef USE_HASH_TABLE_DEDUPLICATE
@ -1532,7 +1532,7 @@ BArrayStore *BLI_array_store_create(uint stride, uint chunk_count)
bs->info.accum_read_ahead_bytes = bs->info.accum_read_ahead_len * stride;
#else
bs->info.accum_read_ahead_bytes = std::min((size_t)BCHUNK_HASH_LEN, chunk_count) * stride;
bs->info.accum_read_ahead_bytes = std::min(size_t(BCHUNK_HASH_LEN), chunk_count) * stride;
#endif
bs->memory.chunk_list = BLI_mempool_create(sizeof(BChunkList), 0, 512, BLI_MEMPOOL_NOP);
@ -1805,7 +1805,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
goto user_finally;
}
}
if (!(BLI_mempool_len(bs->memory.chunk_list) == (int)BLI_ghash_len(chunk_list_map))) {
if (!(BLI_mempool_len(bs->memory.chunk_list) == int(BLI_ghash_len(chunk_list_map)))) {
ok = false;
goto user_finally;
}
@ -1819,7 +1819,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
totrefs += 1;
}
}
if (!(BLI_mempool_len(bs->memory.chunk) == (int)BLI_ghash_len(chunk_map))) {
if (!(BLI_mempool_len(bs->memory.chunk) == int(BLI_ghash_len(chunk_map)))) {
ok = false;
goto user_finally;
}

View File

@ -536,7 +536,7 @@ void BLI_get_short_name(char short_name[256], const char *filepath)
GetShortPathNameW(filepath_16, short_name_16, 256);
for (i = 0; i < 256; i++) {
short_name[i] = (char)short_name_16[i];
short_name[i] = char(short_name_16[i]);
}
UTF16_UN_ENCODE(filepath);

View File

@ -147,8 +147,8 @@ static void bicubic_interpolation(
}
#endif
int iu = (int)floor(u);
int iv = (int)floor(v);
int iu = int(floor(u));
int iv = int(floor(v));
/* Sample area entirely outside image? */
if (iu + 1 < 0 || iu > width - 1 || iv + 1 < 0 || iv > height - 1) {
@ -156,8 +156,8 @@ static void bicubic_interpolation(
return;
}
float frac_u = u - (float)iu;
float frac_v = v - (float)iv;
float frac_u = u - float(iu);
float frac_v = v - float(iv);
float4 out{0.0f};
@ -259,7 +259,7 @@ BLI_INLINE void bilinear_fl_impl(const float *buffer,
float uf = floorf(u);
float vf = floorf(v);
x1 = (int)uf;
x1 = int(uf);
x2 = x1 + 1;
y1 = int(vf);
y2 = y1 + 1;
@ -445,9 +445,9 @@ uchar4 interpolate_bilinear_byte(const uchar *buffer, int width, int height, flo
float uf = floorf(u);
float vf = floorf(v);
int x1 = (int)uf;
int x1 = int(uf);
int x2 = x1 + 1;
int y1 = (int)vf;
int y1 = int(vf);
int y2 = y1 + 1;
/* Completely outside of the image? */
@ -493,10 +493,10 @@ uchar4 interpolate_bilinear_byte(const uchar *buffer, int width, int height, flo
float a_mb = a * (1.0f - b);
float ma_mb = (1.0f - a) * (1.0f - b);
res.x = (uchar)(ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f);
res.y = (uchar)(ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f);
res.z = (uchar)(ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f);
res.w = (uchar)(ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3] + 0.5f);
res.x = uchar(ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f);
res.y = uchar(ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f);
res.z = uchar(ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f);
res.w = uchar(ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3] + 0.5f);
#endif
return res;
@ -535,9 +535,9 @@ uchar4 interpolate_bilinear_wrap_byte(const uchar *buffer, int width, int height
float uf = floorf(u);
float vf = floorf(v);
int x1 = (int)uf;
int x1 = int(uf);
int x2 = x1 + 1;
int y1 = (int)vf;
int y1 = int(vf);
int y2 = y1 + 1;
/* Wrap interpolation pixels if needed. */
@ -728,7 +728,7 @@ void BLI_ewa_filter(const int width,
/* Scaling `dxt` / `dyt` by full resolution can cause overflow because of huge A/B/C and esp.
* F values, scaling by aspect ratio alone does the opposite, so try something in between
* instead. */
const float ff2 = (float)width, ff = sqrtf(ff2), q = (float)height / ff;
const float ff2 = float(width), ff = sqrtf(ff2), q = float(height) / ff;
const float Ux = du[0] * ff, Vx = du[1] * q, Uy = dv[0] * ff, Vy = dv[1] * q;
float A = Vx * Vx + Vy * Vy;
float B = -2.0f * (Ux * Vx + Uy * Vy);
@ -770,8 +770,8 @@ void BLI_ewa_filter(const int width,
V0 = uv[1] * float(height);
u1 = int(floorf(U0 - ue));
u2 = int(ceilf(U0 + ue));
v1 = (int)floorf(V0 - ve);
v2 = (int)ceilf(V0 + ve);
v1 = int(floorf(V0 - ve));
v2 = int(ceilf(V0 + ve));
/* sane clamping to avoid unnecessarily huge loops */
/* NOTE: if eccentricity gets clamped (see above),
@ -786,7 +786,7 @@ void BLI_ewa_filter(const int width,
if (V0 - float(v1) > EWA_MAXIDX) {
v1 = int(V0) - EWA_MAXIDX;
}
if ((float)v2 - V0 > EWA_MAXIDX) {
if (float(v2) - V0 > EWA_MAXIDX) {
v2 = int(V0) + EWA_MAXIDX;
}
@ -807,7 +807,7 @@ void BLI_ewa_filter(const int width,
d = 0.0f;
zero_v4(result);
for (v = v1; v <= v2; v++) {
const float V = (float)v - V0;
const float V = float(v) - V0;
float DQ = ac1 + B * V;
float Q = (C * V + BU) * V + ac2;
for (u = u1; u <= u2; u++) {

View File

@ -128,7 +128,7 @@ double BLI_dir_free_space(const char *dir)
GetDiskFreeSpace(tmp, &sectorspc, &bytesps, &freec, &clusters);
return (double)(freec * bytesps * sectorspc);
return double(freec * bytesps * sectorspc);
#else
# ifdef USE_STATFS_STATVFS

View File

@ -1076,7 +1076,7 @@ int BLI_str_utf8_offset_to_column(const char *str, const size_t str_len, const i
while (offset < offset_target_clamp) {
const uint code = BLI_str_utf8_as_unicode_step_safe(str, str_len, &offset);
column += BLI_wcwidth_safe(code);
BLI_assert(offset <= (size_t)offset_target); /* See DOXY section comment. */
BLI_assert(offset <= size_t(offset_target)); /* See DOXY section comment. */
}
return column;
}
@ -1109,7 +1109,7 @@ int BLI_str_utf8_offset_to_column_with_tabs(const char *str,
const uint code = BLI_str_utf8_as_unicode_step_safe(str, str_len, &offset);
/* The following line is the only change compared with #BLI_str_utf8_offset_to_column. */
column += (code == '\t') ? (tab_width - (column % tab_width)) : BLI_wcwidth_safe(code);
BLI_assert(offset <= (size_t)offset_target); /* See DOXY section comment. */
BLI_assert(offset <= size_t(offset_target)); /* See DOXY section comment. */
}
return column;
}

View File

@ -1381,7 +1381,7 @@ static KeyingSet *keyingset_get_from_op_with_error(wmOperator *op, PropertyRNA *
char type_id[MAX_ID_NAME - 2];
RNA_property_string_get(op->ptr, prop, type_id);
if (strcmp(type_id, "__ACTIVE__") == 0) {
if (STREQ(type_id, "__ACTIVE__")) {
ks = ANIM_keyingset_get_from_enum_type(scene, scene->active_keyingset);
}
else {

View File

@ -527,8 +527,8 @@ static bool gpencil_frame_snap_cframe(bGPDframe *gpf, Scene *scene)
static bool gpencil_frame_snap_nearmarker(bGPDframe *gpf, Scene *scene)
{
if (gpf->flag & GP_FRAME_SELECT) {
gpf->framenum = (int)ED_markers_find_nearest_marker_time(&scene->markers,
float(gpf->framenum));
gpf->framenum = int(
ED_markers_find_nearest_marker_time(&scene->markers, float(gpf->framenum)));
}
return false;
}