Cleanup: redundant checks

In some cases moved the checks into asserts,
to ensure changes in the future don't cause
the checks to become necessary again.
This commit is contained in:
2020-03-15 21:48:35 +11:00
parent 80edc0e972
commit 4be4c06671
8 changed files with 15 additions and 18 deletions

View File

@@ -788,7 +788,7 @@ void BM_log_redo(BMesh *bm, BMLog *log)
/* Currently at the beginning of the undo stack, move to first entry */
entry = log->entries.first;
}
else if (entry && entry->next) {
else if (entry->next) {
/* Move to next undo entry */
entry = entry->next;
}

View File

@@ -591,11 +591,9 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
DEG_relations_tag_update(bmain);
}
else {
if (id) {
Main *bmain = CTX_data_main(C);
id_single_user(C, id, &template_ui->ptr, template_ui->prop);
DEG_relations_tag_update(bmain);
}
Main *bmain = CTX_data_main(C);
id_single_user(C, id, &template_ui->ptr, template_ui->prop);
DEG_relations_tag_update(bmain);
}
}
break;

View File

@@ -3382,11 +3382,9 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
if (use_add) {
/* In add mode, we add relative shape key offset. */
if (kb) {
const float *rco = CustomData_bmesh_get_n(
&em->bm->vdata, eve->head.data, CD_SHAPEKEY, kb->relative);
sub_v3_v3v3(co, co, rco);
}
const float *rco = CustomData_bmesh_get_n(
&em->bm->vdata, eve->head.data, CD_SHAPEKEY, kb->relative);
sub_v3_v3v3(co, co, rco);
madd_v3_v3fl(eve->co, co, blend);
}

View File

@@ -282,7 +282,9 @@ static bool ed_object_mode_generic_exit_ex(struct Main *bmain,
ED_object_posemode_exit_ex(bmain, ob);
}
}
else if ((ob->type == OB_GPENCIL) && ((ob->mode & OB_MODE_OBJECT) == 0)) {
else if (ob->type == OB_GPENCIL) {
/* Accounted for above. */
BLI_assert((ob->mode & OB_MODE_OBJECT) == 0);
if (only_test) {
return true;
}

View File

@@ -291,7 +291,7 @@ static int txtfmt_py_literal_numeral(const char *string, char prev_fmt)
}
/* Previous was a number; if immediately followed by '.' it's a floating point decimal number.
* Note: keep the decimal point, it's needed to allow leading zeros. */
if ((prev_fmt == FMT_TYPE_NUMERAL) && (first == '.')) {
if (first == '.') {
return txtfmt_py_find_numeral_inner(string);
}
/* "Imaginary" part of a complex number ends with 'j' */

View File

@@ -97,7 +97,8 @@ void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buf
if (buf) {
size_t rowstride = movie->header->Width * 3;
if ((bits != 16) && (movie->header->Width % 2)) {
BLI_assert(bits != 16);
if (movie->header->Width % 2) {
rowstride++;
}

View File

@@ -3516,7 +3516,7 @@ static int previews_clear_exec(bContext *C, wmOperator *op)
BKE_idcode_to_idfilter(GS(id->name)) & id_filters);
#endif
if (!id || !(BKE_idcode_to_idfilter(GS(id->name)) & id_filters)) {
if (!(BKE_idcode_to_idfilter(GS(id->name)) & id_filters)) {
continue;
}

View File

@@ -525,9 +525,7 @@ static void build_pict_list_ex(
BLI_stringenc(filepath, fp_decoded.head, fp_decoded.tail, fp_decoded.digits, fp_framenr);
while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) {
if (hasevent) {
GHOST_DispatchEvents(g_WS.ghost_system);
}
GHOST_DispatchEvents(g_WS.ghost_system);
if (ps->loading == false) {
return;
}