Cleanup: remove redundant parenthesis (especially with macros)

This commit is contained in:
2022-09-25 22:41:22 +10:00
parent 21d77a417e
commit 0419ee871f
34 changed files with 57 additions and 57 deletions

View File

@@ -2629,7 +2629,7 @@ static int gpencil_material_find_index_by_name(Object *ob, const char *name)
{
for (int i = 0; i < ob->totcol; i++) {
Material *ma = BKE_object_material_get(ob, i + 1);
if ((ma != nullptr) && (ma->gp_style != nullptr) && (STREQ(ma->id.name + 2, name))) {
if ((ma != nullptr) && (ma->gp_style != nullptr) && STREQ(ma->id.name + 2, name)) {
return i;
}
}

View File

@@ -2986,7 +2986,7 @@ static void image_free_tile(Image *ima, ImageTile *tile)
for (int i = 0; i < TEXTARGET_COUNT; i++) {
/* Only two textures depends on all tiles, so if this is a secondary tile we can keep the other
* two. */
if (tile != ima->tiles.first && !(ELEM(i, TEXTARGET_2D_ARRAY, TEXTARGET_TILE_MAPPING))) {
if (tile != ima->tiles.first && !ELEM(i, TEXTARGET_2D_ARRAY, TEXTARGET_TILE_MAPPING)) {
continue;
}

View File

@@ -361,10 +361,10 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
mloopuv->uv[1] = (v % dl->nr) / float(orco_sizeu);
/* cyclic correction */
if ((ELEM(i, 1, 2)) && mloopuv->uv[0] == 0.0f) {
if (ELEM(i, 1, 2) && mloopuv->uv[0] == 0.0f) {
mloopuv->uv[0] = 1.0f;
}
if ((ELEM(i, 0, 1)) && mloopuv->uv[1] == 0.0f) {
if (ELEM(i, 0, 1) && mloopuv->uv[1] == 0.0f) {
mloopuv->uv[1] = 1.0f;
}
}

View File

@@ -835,7 +835,7 @@ struct LoopSplitTaskDataCommon {
#define INDEX_UNSET INT_MIN
#define INDEX_INVALID -1
/* See comment about edge_to_loops below. */
#define IS_EDGE_SHARP(_e2l) (ELEM((_e2l)[1], INDEX_UNSET, INDEX_INVALID))
#define IS_EDGE_SHARP(_e2l) ELEM((_e2l)[1], INDEX_UNSET, INDEX_INVALID)
static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
const bool check_angle,

View File

@@ -1417,8 +1417,8 @@ void nodeUnregisterType(bNodeType *nt)
bool nodeTypeUndefined(const bNode *node)
{
return (node->typeinfo == &NodeTypeUndefined) ||
((ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) && node->id &&
ID_IS_LINKED(node->id) && (node->id->tag & LIB_TAG_MISSING));
(ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id && ID_IS_LINKED(node->id) &&
(node->id->tag & LIB_TAG_MISSING));
}
GHashIterator *nodeTypeGetIterator()

View File

@@ -1402,15 +1402,15 @@ ModifierData *BKE_object_active_modifier(const Object *ob)
bool BKE_object_supports_modifiers(const Object *ob)
{
return (ELEM(ob->type,
OB_MESH,
OB_CURVES,
OB_CURVES_LEGACY,
OB_SURF,
OB_FONT,
OB_LATTICE,
OB_POINTCLOUD,
OB_VOLUME));
return ELEM(ob->type,
OB_MESH,
OB_CURVES,
OB_CURVES_LEGACY,
OB_SURF,
OB_FONT,
OB_LATTICE,
OB_POINTCLOUD,
OB_VOLUME);
}
bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type)
@@ -5450,7 +5450,7 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
}
/* Skip sub-frame if object is parented to vertex of a dynamic paint canvas. */
if (no_update && (ELEM(ob->partype, PARVERT1, PARVERT3))) {
if (no_update && ELEM(ob->partype, PARVERT1, PARVERT3)) {
return false;
}

View File

@@ -126,8 +126,8 @@
/* ********* my write, buffered writing with minimum size chunks ************ */
/* Use optimal allocation since blocks of this size are kept in memory for undo. */
#define MEM_BUFFER_SIZE (MEM_SIZE_OPTIMAL(1 << 17)) /* 128kb */
#define MEM_CHUNK_SIZE (MEM_SIZE_OPTIMAL(1 << 15)) /* ~32kb */
#define MEM_BUFFER_SIZE MEM_SIZE_OPTIMAL(1 << 17) /* 128kb */
#define MEM_CHUNK_SIZE MEM_SIZE_OPTIMAL(1 << 15) /* ~32kb */
#define ZSTD_BUFFER_SIZE (1 << 21) /* 2mb */
#define ZSTD_CHUNK_SIZE (1 << 20) /* 1mb */

View File

@@ -34,7 +34,7 @@ static int extrapolate9(float *E0,
do { \
*DST = *SRC; \
} while (0)
if ((!PEQ(B, H)) && (!PEQ(D, F))) {
if (!PEQ(B, H) && !PEQ(D, F)) {
if (PEQ(D, B)) {
PCPY(E0, D);
}

View File

@@ -54,7 +54,7 @@ string ComponentNode::OperationIDKey::identifier() const
bool ComponentNode::OperationIDKey::operator==(const OperationIDKey &other) const
{
return (opcode == other.opcode) && (STREQ(name, other.name)) && (name_tag == other.name_tag);
return (opcode == other.opcode) && STREQ(name, other.name) && (name_tag == other.name_tag);
}
uint64_t ComponentNode::OperationIDKey::hash() const

View File

@@ -154,8 +154,8 @@ float Light::attenuation_radius_get(const ::Light *la, float light_threshold, fl
void Light::shape_parameters_set(const ::Light *la, const float scale[3])
{
if (la->type == LA_AREA) {
float area_size_y = (ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE)) ? la->area_sizey :
la->area_size;
float area_size_y = ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE) ? la->area_sizey :
la->area_size;
_area_size_x = max_ff(0.003f, la->area_size * scale[0] * 0.5f);
_area_size_y = max_ff(0.003f, area_size_y * scale[1] * 0.5f);
/* For volume point lighting. */

View File

@@ -96,7 +96,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
(GPENCIL_EDIT_MODE(gpd) &&
(ts->gpencil_selectmode_edit != GP_SELECTMODE_STROKE));
if ((!GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) &&
if (!GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd) &&
((!GPENCIL_VERTEX_MODE(gpd) && !GPENCIL_PAINT_MODE(gpd)) || use_vertex_mask)) {
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_BLEND_ALPHA;

View File

@@ -86,7 +86,7 @@ static bool gpencil_bake_grease_pencil_animation_poll(bContext *C)
}
/* Check if grease pencil or empty for dupli groups. */
if ((obact == nullptr) || (!ELEM(obact->type, OB_GPENCIL, OB_EMPTY))) {
if ((obact == nullptr) || !ELEM(obact->type, OB_GPENCIL, OB_EMPTY)) {
return false;
}

View File

@@ -84,7 +84,7 @@ bool ui_but_is_interactive_ex(const uiBut *but, const bool labeledit, const bool
return false;
}
if ((but->type == UI_BTYPE_TEXT) &&
(ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS)) && !labeledit) {
ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS) && !labeledit) {
return false;
}
if ((but->type == UI_BTYPE_LISTROW) && labeledit) {
@@ -103,7 +103,7 @@ bool UI_but_is_utf8(const uiBut *but)
{
if (but->rnaprop) {
const int subtype = RNA_property_subtype(but->rnaprop);
return !(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME, PROP_BYTESTRING));
return !ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME, PROP_BYTESTRING);
}
return !(but->flag & UI_BUT_NO_UTF8);
}

View File

@@ -165,10 +165,10 @@ static void ui_popup_block_position(wmWindow *window,
dir1 &= (UI_DIR_UP | UI_DIR_DOWN);
}
if ((dir2 == 0) && (ELEM(dir1, UI_DIR_LEFT, UI_DIR_RIGHT))) {
if ((dir2 == 0) && ELEM(dir1, UI_DIR_LEFT, UI_DIR_RIGHT)) {
dir2 = UI_DIR_DOWN;
}
if ((dir2 == 0) && (ELEM(dir1, UI_DIR_UP, UI_DIR_DOWN))) {
if ((dir2 == 0) && ELEM(dir1, UI_DIR_UP, UI_DIR_DOWN)) {
dir2 = UI_DIR_LEFT;
}

View File

@@ -435,7 +435,7 @@ eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout,
/* Only buttons that can be edited as text. */
const bool use_activate_init = ((prop == prop_activate_init) &&
(ELEM(type, PROP_STRING, PROP_INT, PROP_FLOAT)));
ELEM(type, PROP_STRING, PROP_INT, PROP_FLOAT));
if (use_activate_init) {
uiLayoutSetActivateInit(col, true);

View File

@@ -328,7 +328,7 @@ bool paint_use_opacity_masking(Brush *brush)
{
return ((brush->flag & BRUSH_AIRBRUSH) || (brush->flag & BRUSH_DRAG_DOT) ||
(brush->flag & BRUSH_ANCHORED) ||
(ELEM(brush->imagepaint_tool, PAINT_TOOL_SMEAR, PAINT_TOOL_SOFTEN)) ||
ELEM(brush->imagepaint_tool, PAINT_TOOL_SMEAR, PAINT_TOOL_SOFTEN) ||
(brush->imagepaint_tool == PAINT_TOOL_FILL) ||
(brush->flag & BRUSH_USE_GRADIENT) ||
(brush->mtex.tex && !ELEM(brush->mtex.brush_map_mode,

View File

@@ -2459,7 +2459,7 @@ static void wpaint_do_symmetrical_brush_actions(
/* symm is a bit combination of XYZ - 1 is mirror
* X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
for (i = 1; i <= symm; i++) {
if (symm & i && (symm != 5 || i != 3) && (symm != 6 || (!ELEM(i, 3, 5)))) {
if (symm & i && (symm != 5 || i != 3) && (symm != 6 || !ELEM(i, 3, 5))) {
cache->mirror_symmetry_pass = i;
cache->radial_symmetry_pass = 0;
SCULPT_cache_calc_brushdata_symm(cache, i, 0, 0);
@@ -3807,7 +3807,7 @@ static void vpaint_do_symmetrical_brush_actions(
/* symm is a bit combination of XYZ - 1 is mirror
* X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
for (i = 1; i <= symm; i++) {
if (symm & i && (symm != 5 || i != 3) && (symm != 6 || (!ELEM(i, 3, 5)))) {
if (symm & i && (symm != 5 || i != 3) && (symm != 6 || !ELEM(i, 3, 5))) {
cache->mirror_symmetry_pass = i;
cache->radial_symmetry_pass = 0;
SCULPT_cache_calc_brushdata_symm(cache, i, 0, 0);

View File

@@ -49,7 +49,7 @@ static bool vertex_weight_paint_mode_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
Mesh *me = BKE_mesh_from_object(ob);
return (ob && (ELEM(ob->mode, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT))) &&
return (ob && ELEM(ob->mode, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT)) &&
(me && me->totpoly && !me->deform_verts().is_empty());
}

View File

@@ -938,7 +938,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe
uiItemR(
row, &tex_ptr, "noise_basis_2", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
row = uiLayoutRow(col, false);
uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING)));
uiLayoutSetActive(row, !ELEM(tex->stype, TEX_BAND, TEX_RING));
uiItemR(row, &tex_ptr, "noise_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
break;

View File

@@ -658,7 +658,7 @@ static bool node_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent
{
if (drag->type == WM_DRAG_PATH) {
/* rule might not work? */
return (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE));
return ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE);
}
return WM_drag_is_ID_type(drag, ID_IM);
}

View File

@@ -21,7 +21,7 @@ static void outliner_context_selected_ids_recursive(const SpaceOutliner &space_o
{
tree_iterator::all(space_outliner, [&](const TreeElement *te) {
const TreeStoreElem *tse = TREESTORE(te);
if ((tse->flag & TSE_SELECTED) && (ELEM(tse->type, TSE_SOME_ID, TSE_LAYER_COLLECTION))) {
if ((tse->flag & TSE_SELECTED) && ELEM(tse->type, TSE_SOME_ID, TSE_LAYER_COLLECTION)) {
CTX_data_id_list_add(result, tse->id);
}
});

View File

@@ -632,7 +632,7 @@ static bool view3d_ima_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event
}
if (drag->type == WM_DRAG_PATH) {
/* rule might not work? */
return (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE));
return ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE);
}
return WM_drag_is_ID_type(drag, ID_IM);

View File

@@ -229,7 +229,7 @@ static int lib_id_fake_user_toggle_exec(bContext *C, wmOperator *op)
ID *id = (ID *)idptr.data;
if (!BKE_id_is_editable(CTX_data_main(C), id) ||
(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS))) {
ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS)) {
BKE_report(op->reports, RPT_ERROR, "Data-block type does not support fake user");
return OPERATOR_CANCELLED;
}

View File

@@ -593,14 +593,14 @@ int Stroke::Resample(int iNPoints)
for (vector<StrokeSegment>::iterator s = strokeSegments.begin(), send = strokeSegments.end();
s != send;
++s) {
newVertices.push_back(&(*(s->_begin)));
newVertices.push_back(&*(s->_begin));
if (s->_sampling < _sampling) {
_sampling = s->_sampling;
}
t = s->_sampling / s->_length;
for (int i = 0; i < s->_n; ++i) {
newVertex = new StrokeVertex(&(*(s->_begin)), &(*(s->_end)), t);
newVertex = new StrokeVertex(&*(s->_begin), &*(s->_end), t);
newVertices.push_back(newVertex);
t += s->_sampling / s->_length;
}

View File

@@ -1289,7 +1289,7 @@ void ViewMapBuilder::computeCusps(ViewMap *ioViewMap)
if (_pRenderMonitor && _pRenderMonitor->testBreak()) {
break;
}
if ((!((*ve)->getNature() & Nature::SILHOUETTE)) || (!((*ve)->fedgeA()->isSmooth()))) {
if (!((*ve)->getNature() & Nature::SILHOUETTE) || !((*ve)->fedgeA()->isSmooth())) {
continue;
}
FEdge *fe = (*ve)->fedgeA();
@@ -2313,8 +2313,8 @@ struct silhouette_binary_rule : public binary_rule<segment, segment> {
FEdge *f1 = s1.edge();
FEdge *f2 = s2.edge();
if ((!(((f1)->getNature() & Nature::SILHOUETTE) || ((f1)->getNature() & Nature::BORDER))) &&
(!(((f2)->getNature() & Nature::SILHOUETTE) || ((f2)->getNature() & Nature::BORDER)))) {
if (!(((f1)->getNature() & Nature::SILHOUETTE) || ((f1)->getNature() & Nature::BORDER)) &&
!(((f2)->getNature() & Nature::SILHOUETTE) || ((f2)->getNature() & Nature::BORDER))) {
return false;
}

View File

@@ -109,7 +109,7 @@ struct GPUSource {
}
if ((source.find("drw_debug_") != StringRef::not_found) &&
/* Avoid these two files where it makes no sense to add the dependency. */
(!ELEM(filename, "common_debug_draw_lib.glsl", "draw_debug_draw_display_vert.glsl"))) {
!ELEM(filename, "common_debug_draw_lib.glsl", "draw_debug_draw_display_vert.glsl")) {
builtins |= shader::BuiltinBits::USE_DEBUG_DRAW;
}
check_no_quotes();
@@ -140,7 +140,7 @@ struct GPUSource {
if constexpr (check_whole_word) {
/* Fix false positive if something has "enum" as suffix. */
char previous_char = input[offset - 1];
if (!(ELEM(previous_char, '\n', '\t', ' ', ':', '(', ','))) {
if (!ELEM(previous_char, '\n', '\t', ' ', ':', '(', ',')) {
offset += (reversed) ? -1 : 1;
continue;
}

View File

@@ -422,9 +422,9 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo
const UVSample &sample = uv_primvars[layer_idx];
if (!(ELEM(sample.interpolation,
pxr::UsdGeomTokens->faceVarying,
pxr::UsdGeomTokens->vertex))) {
if (!ELEM(sample.interpolation,
pxr::UsdGeomTokens->faceVarying,
pxr::UsdGeomTokens->vertex)) {
std::cerr << "WARNING: unexpected interpolation type " << sample.interpolation
<< " for uv " << layer->name << std::endl;
continue;
@@ -865,7 +865,7 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
pxr::TfToken interp = p.GetInterpolation();
if (!(ELEM(interp, pxr::UsdGeomTokens->faceVarying, pxr::UsdGeomTokens->vertex))) {
if (!ELEM(interp, pxr::UsdGeomTokens->faceVarying, pxr::UsdGeomTokens->vertex)) {
continue;
}

View File

@@ -650,7 +650,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
}
/* Quick test to see if we can return early. */
if (!(ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP)) || (mesh->totvert == 0) ||
if (!ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP) || (mesh->totvert == 0) ||
BLI_listbase_is_empty(&mesh->vertex_group_names)) {
return mesh;
}

View File

@@ -685,7 +685,7 @@ const char *node_cmp_rlayers_sock_to_pass(int sock_index)
}
const char *name = cmp_node_rlayers_out[sock_index].name;
/* Exception for alpha, which is derived from Combined. */
return (STREQ(name, "Alpha")) ? RE_PASSNAME_COMBINED : name;
return STREQ(name, "Alpha") ? RE_PASSNAME_COMBINED : name;
}
namespace blender::nodes::node_composite_render_layer_cc {

View File

@@ -151,7 +151,7 @@ static bool colinear_f3_f3_f3(const float3 p1, const float3 p2, const float3 p3)
{
const float3 a = math::normalize(p2 - p1);
const float3 b = math::normalize(p3 - p1);
return (ELEM(a, b, b * -1.0f));
return ELEM(a, b, b * -1.0f);
}
static Curves *create_arc_curve_from_points(const int resolution,

View File

@@ -98,7 +98,7 @@ static bool colinear_f3_f3_f3(const float3 p1, const float3 p2, const float3 p3)
{
const float3 a = math::normalize(p2 - p1);
const float3 b = math::normalize(p3 - p1);
return (ELEM(a, b, b * -1.0f));
return ELEM(a, b, b * -1.0f);
}
static Curves *create_point_circle_curve(

View File

@@ -173,7 +173,7 @@ static void node_shader_update_tex_voronoi(bNodeTree *ntree, bNode *node)
outWSock,
storage.feature != SHD_VORONOI_DISTANCE_TO_EDGE &&
storage.feature != SHD_VORONOI_N_SPHERE_RADIUS &&
(ELEM(storage.dimensions, 1, 4)));
ELEM(storage.dimensions, 1, 4));
nodeSetSocketAvailability(ntree, outRadiusSock, storage.feature == SHD_VORONOI_N_SPHERE_RADIUS);
}

View File

@@ -585,7 +585,7 @@ wmDragAsset *WM_drag_get_asset_data(const wmDrag *drag, int idcode)
}
wmDragAsset *asset_drag = static_cast<wmDragAsset *>(drag->poin);
return (ELEM(idcode, 0, asset_drag->id_type)) ? asset_drag : nullptr;
return ELEM(idcode, 0, asset_drag->id_type) ? asset_drag : nullptr;
}
AssetMetaData *WM_drag_get_asset_meta_data(const wmDrag *drag, int idcode)

View File

@@ -567,7 +567,7 @@ void wm_event_do_notifiers(bContext *C)
}
if (note->window == win ||
(note->window == nullptr && (ELEM(note->reference, nullptr, scene)))) {
(note->window == nullptr && ELEM(note->reference, nullptr, scene))) {
if (note->category == NC_SCENE) {
if (note->data == ND_FRAME) {
do_anim = true;