Skip to content

Commit 1193d3b

Browse files
committed
removed unecessary if statements to check for nullptr
1 parent d0c4cb9 commit 1193d3b

File tree

1 file changed

+21
-49
lines changed

1 file changed

+21
-49
lines changed

libs/libarchfpga/src/arch_util.cpp

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ static void free_pb_graph(t_pb_graph_node* pb_graph_node) {
305305

306306
static void free_pb_type(t_pb_type* pb_type) {
307307
vtr::free(pb_type->name);
308-
if (pb_type->blif_model)
309-
vtr::free(pb_type->blif_model);
308+
vtr::free(pb_type->blif_model);
310309

311310
for (int i = 0; i < pb_type->num_modes; ++i) {
312311
for (int j = 0; j < pb_type->modes[i].num_pb_type_children; ++j) {
@@ -320,55 +319,34 @@ static void free_pb_type(t_pb_type* pb_type) {
320319
vtr::free(pb_type->modes[i].interconnect[j].name);
321320

322321
for (int k = 0; k < pb_type->modes[i].interconnect[j].num_annotations; ++k) {
323-
if (pb_type->modes[i].interconnect[j].annotations[k].clock)
324-
vtr::free(pb_type->modes[i].interconnect[j].annotations[k].clock);
325-
if (pb_type->modes[i].interconnect[j].annotations[k].input_pins) {
326-
vtr::free(pb_type->modes[i].interconnect[j].annotations[k].input_pins);
327-
}
328-
if (pb_type->modes[i].interconnect[j].annotations[k].output_pins) {
329-
vtr::free(pb_type->modes[i].interconnect[j].annotations[k].output_pins);
330-
}
322+
vtr::free(pb_type->modes[i].interconnect[j].annotations[k].clock);
323+
vtr::free(pb_type->modes[i].interconnect[j].annotations[k].input_pins);
324+
vtr::free(pb_type->modes[i].interconnect[j].annotations[k].output_pins);
331325
}
332326
delete[] pb_type->modes[i].interconnect[j].annotations;
333-
if (pb_type->modes[i].interconnect[j].interconnect_power)
334-
delete pb_type->modes[i].interconnect[j].interconnect_power;
327+
delete pb_type->modes[i].interconnect[j].interconnect_power;
335328
}
336-
if (pb_type->modes[i].interconnect)
337-
delete[] pb_type->modes[i].interconnect;
338-
if (pb_type->modes[i].mode_power)
339-
delete (pb_type->modes[i].mode_power);
329+
delete[] pb_type->modes[i].interconnect;
330+
delete (pb_type->modes[i].mode_power);
340331
}
341-
if (pb_type->modes)
342-
delete[] pb_type->modes;
332+
333+
delete[] pb_type->modes;
343334

344335
for (int i = 0; i < pb_type->num_annotations; ++i) {
345-
346-
if (pb_type->annotations[i].input_pins) {
347-
vtr::free(pb_type->annotations[i].input_pins);
348-
}
349-
if (pb_type->annotations[i].output_pins) {
350-
vtr::free(pb_type->annotations[i].output_pins);
351-
}
352-
if (pb_type->annotations[i].clock) {
353-
vtr::free(pb_type->annotations[i].clock);
354-
}
355-
}
356-
if (pb_type->annotations) {
357-
delete[] pb_type->annotations;
336+
vtr::free(pb_type->annotations[i].input_pins);
337+
vtr::free(pb_type->annotations[i].output_pins);
338+
vtr::free(pb_type->annotations[i].clock);
358339
}
340+
delete[] pb_type->annotations;
341+
359342

360-
if (pb_type->pb_type_power) {
361-
delete pb_type->pb_type_power;
362-
}
343+
delete pb_type->pb_type_power;
344+
363345

364346
for (int i = 0; i < pb_type->num_ports; ++i) {
365347
vtr::free(pb_type->ports[i].name);
366-
if (pb_type->ports[i].port_class) {
367-
vtr::free(pb_type->ports[i].port_class);
368-
}
369-
if (pb_type->ports[i].port_power) {
370-
delete pb_type->ports[i].port_power;
371-
}
348+
vtr::free(pb_type->ports[i].port_class);
349+
delete pb_type->ports[i].port_power;
372350
}
373351
delete[] pb_type->ports;
374352
}
@@ -619,15 +597,9 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
619597
lut_pb_type->modes[1].pb_type_children);
620598
/* moved annotations to child so delete old annotations */
621599
for (i = 0; i < lut_pb_type->num_annotations; i++) {
622-
if (lut_pb_type->annotations[i].input_pins) {
623-
vtr::free(lut_pb_type->annotations[i].input_pins);
624-
}
625-
if (lut_pb_type->annotations[i].output_pins) {
626-
vtr::free(lut_pb_type->annotations[i].output_pins);
627-
}
628-
if (lut_pb_type->annotations[i].clock) {
629-
vtr::free(lut_pb_type->annotations[i].clock);
630-
}
600+
vtr::free(lut_pb_type->annotations[i].input_pins);
601+
vtr::free(lut_pb_type->annotations[i].output_pins);
602+
vtr::free(lut_pb_type->annotations[i].clock);
631603
}
632604
lut_pb_type->num_annotations = 0;
633605
delete[] lut_pb_type->annotations;

0 commit comments

Comments
 (0)