improved performance

This commit is contained in:
Mario Hüttel 2018-05-10 01:36:01 +02:00
parent e469e614ab
commit 628c1ad8d0

View File

@ -165,7 +165,8 @@ static GList *append_library(GList *curr_list)
return g_list_append(curr_list, lib); return g_list_append(curr_list, lib);
} }
static GList *append_graphics(GList *curr_list, enum graphics_type type) static GList *append_graphics(GList *curr_list, enum graphics_type type,
struct gds_graphics **graphics_ptr)
{ {
struct gds_graphics *gfx; struct gds_graphics *gfx;
@ -178,6 +179,10 @@ static GList *append_graphics(GList *curr_list, enum graphics_type type)
gfx->type = type; gfx->type = type;
} else } else
return NULL; return NULL;
if (graphics_ptr)
*graphics_ptr = gfx;
return g_list_append(curr_list, gfx); return g_list_append(curr_list, gfx);
} }
@ -194,7 +199,7 @@ static GList *append_vertex(GList *curr_list, int x, int y)
return g_list_append(curr_list, vertex); return g_list_append(curr_list, vertex);
} }
static GList *append_cell(GList *curr_list) static GList *append_cell(GList *curr_list, struct gds_cell **cell_ptr)
{ {
struct gds_cell *cell; struct gds_cell *cell;
@ -205,11 +210,14 @@ static GList *append_cell(GList *curr_list)
cell->name[0] = 0; cell->name[0] = 0;
} else } else
return NULL; return NULL;
/* return cell */
if (cell_ptr)
*cell_ptr = cell;
return g_list_append(curr_list, cell); return g_list_append(curr_list, cell);
} }
static GList *append_cell_ref(GList *curr_list) static GList *append_cell_ref(GList *curr_list, struct gds_cell_instance **instance_ptr)
{ {
struct gds_cell_instance *inst; struct gds_cell_instance *inst;
@ -224,6 +232,9 @@ static GList *append_cell_ref(GList *curr_list)
} else } else
return NULL; return NULL;
if (instance_ptr)
*instance_ptr = inst;
return g_list_append(curr_list, inst); return g_list_append(curr_list, inst);
} }
@ -422,15 +433,13 @@ int parse_gds_from_file(const char *filename, GList **library_list)
printf("Leaving Library\n"); printf("Leaving Library\n");
break; break;
case BGNSTR: case BGNSTR:
current_lib->cells = append_cell(current_lib->cells); current_lib->cells = append_cell(current_lib->cells, &current_cell);
if (current_lib->cells == NULL) { if (current_lib->cells == NULL) {
GDS_ERROR("Allocating memory failed"); GDS_ERROR("Allocating memory failed");
run = -3; run = -3;
break; break;
} }
printf("Entering Cell\n"); printf("Entering Cell\n");
current_cell = (struct gds_cell *)
g_list_last(current_lib->cells)->data;
break; break;
case ENDSTR: case ENDSTR:
if (current_cell == NULL) { if (current_cell == NULL) {
@ -454,13 +463,13 @@ int parse_gds_from_file(const char *filename, GList **library_list)
run = -3; run = -3;
break; break;
} }
current_cell->graphic_objs = append_graphics(current_cell->graphic_objs, GRAPHIC_POLYGON); current_cell->graphic_objs = append_graphics(current_cell->graphic_objs,
GRAPHIC_POLYGON, &current_graphics);
if (current_cell->graphic_objs == NULL) { if (current_cell->graphic_objs == NULL) {
GDS_ERROR("Memory allocation failed"); GDS_ERROR("Memory allocation failed");
run = -4; run = -4;
break; break;
} }
current_graphics = (struct gds_graphics *) g_list_last(current_cell->graphic_objs)->data;
printf("\tEntering boundary\n"); printf("\tEntering boundary\n");
break; break;
case SREF: case SREF:
@ -469,14 +478,14 @@ int parse_gds_from_file(const char *filename, GList **library_list)
run = -3; run = -3;
break; break;
} }
current_cell->child_cells = append_cell_ref(current_cell->child_cells); current_cell->child_cells = append_cell_ref(current_cell->child_cells,
&current_s_reference);
if (current_cell->child_cells == NULL) { if (current_cell->child_cells == NULL) {
GDS_ERROR("Memory allocation failed"); GDS_ERROR("Memory allocation failed");
run = -4; run = -4;
break; break;
} }
current_s_reference = (struct gds_cell_instance *) g_list_last(current_cell->child_cells)->data;
printf("\tEntering reference\n"); printf("\tEntering reference\n");
break; break;
case PATH: case PATH:
@ -485,13 +494,13 @@ int parse_gds_from_file(const char *filename, GList **library_list)
run = -3; run = -3;
break; break;
} }
current_cell->graphic_objs = append_graphics(current_cell->graphic_objs, GRAPHIC_PATH); current_cell->graphic_objs = append_graphics(current_cell->graphic_objs,
GRAPHIC_PATH, &current_graphics);
if (current_cell->graphic_objs == NULL) { if (current_cell->graphic_objs == NULL) {
GDS_ERROR("Memory allocation failed"); GDS_ERROR("Memory allocation failed");
run = -4; run = -4;
break; break;
} }
current_graphics = (struct gds_graphics *) g_list_last(current_cell->graphic_objs)->data;
printf("\tEntering Path\n"); printf("\tEntering Path\n");
break; break;
case ENDEL: case ENDEL: