Skip to content

Commit

Permalink
Refactor: list iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
positively-charged committed Apr 22, 2017
1 parent b3d2ab7 commit 2f9b082
Show file tree
Hide file tree
Showing 19 changed files with 313 additions and 280 deletions.
8 changes: 4 additions & 4 deletions src/cache/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,16 @@ void cache_add( struct cache* cache, struct library* lib ) {
entry->dependency = NULL;
}
// Update entry.
list_iter_t i;
list_iter_init( &i, &lib->files );
struct list_iter i;
list_iterate( &lib->files, &i );
while ( ! list_end( &i ) ) {
struct file_entry* file = list_data( &i );
struct cache_dependency* dep = cache_alloc_dependency( cache,
file->full_path.value );
cache_append_dependency( entry, dep );
list_next( &i );
}
list_iter_init( &i, &lib->import_dircs );
list_iterate( &lib->import_dircs, &i );
while ( ! list_end( &i ) ) {
struct import_dirc* dirc = list_data( &i );
struct file_query query;
Expand Down Expand Up @@ -599,4 +599,4 @@ void print_lifetime( struct cache* cache, struct cache_entry* entry ) {
else {
printf( " time-left=none (entry will be removed)\n" );
}
}
}
12 changes: 6 additions & 6 deletions src/cache/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ void save_file_map( struct saver* saver ) {
WF( saver, F_FILEMAP );
int size = list_size( &saver->lib->files );
WV( saver, F_SIZE, &size );
list_iter_t i;
list_iter_init( &i, &saver->lib->files );
struct list_iter i;
list_iterate( &saver->lib->files, &i );
while ( ! list_end( &i ) ) {
struct file_entry* file = list_data( &i );
WS( saver, F_FILEPATH, file->full_path.value );
Expand All @@ -164,8 +164,8 @@ void save_namespace( struct saver* saver, struct ns_fragment* fragment ) {
}
}
// Save members.
list_iter_t i;
list_iter_init( &i, &fragment->objects );
struct list_iter i;
list_iterate( &fragment->objects, &i );
while ( ! list_end( &i ) ) {
save_namespace_member( saver, list_data( &i ) );
list_next( &i );
Expand Down Expand Up @@ -534,8 +534,8 @@ void save_pos( struct saver* saver, struct pos* pos ) {
}

int map_file( struct saver* saver, int id ) {
list_iter_t i;
list_iter_init( &i, &saver->lib->files );
struct list_iter i;
list_iterate( &saver->lib->files, &i );
int map_id = 0;
while ( ! list_end( &i ) ) {
struct file_entry* file = list_data( &i );
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ static void write_expr_arg( struct codegen* codegen,

void p_visit_inline_asm( struct codegen* codegen,
struct inline_asm* inline_asm ) {
list_iter_t i;
list_iter_init( &i, &inline_asm->args );
struct list_iter i;
list_iterate( &inline_asm->args, &i );
c_unoptimized_opc( codegen, inline_asm->opcode );
while ( ! list_end( &i ) ) {
write_arg( codegen, list_data( &i ) );
Expand Down Expand Up @@ -59,4 +59,4 @@ void write_expr_arg( struct codegen* codegen, struct inline_asm_arg* arg ) {
c_append_string( codegen, string );
}
}
}
}
Loading

0 comments on commit 2f9b082

Please sign in to comment.