Forráskód Böngészése

Add for C++ for loop uses

gingerBill 2 éve
szülő
commit
88b578ca11
2 módosított fájl, 10 hozzáadás és 15 törlés
  1. 5 7
      src/build_settings.cpp
  2. 5 8
      src/checker.cpp

+ 5 - 7
src/build_settings.cpp

@@ -596,9 +596,9 @@ gb_internal void add_library_collection(String name, String path) {
 }
 
 gb_internal bool find_library_collection_path(String name, String *path) {
-	for_array(i, library_collections) {
-		if (library_collections[i].name == name) {
-			if (path) *path = library_collections[i].path;
+	for (auto const &lc : library_collections) {
+		if (lc.name == name) {
+			if (path) *path = lc.path;
 			return true;
 		}
 	}
@@ -1307,8 +1307,7 @@ gb_internal bool check_target_feature_is_enabled(TokenPos pos, String const &tar
 
 	auto items = split_by_comma(target_feature_list);
 	array_free(&items);
-	for_array(i, items) {
-		String const &item = items.data[i];
+	for (String const &item : items) {
 		if (!check_target_feature_is_valid(pos, item)) {
 			error(pos, "Target feature '%.*s' is not valid", LIT(item));
 			return false;
@@ -1328,8 +1327,7 @@ gb_internal void enable_target_feature(TokenPos pos, String const &target_featur
 	defer (mutex_unlock(&bc->target_features_mutex));
 
 	auto items = split_by_comma(target_feature_list);
-	for_array(i, items) {
-		String const &item = items.data[i];
+	for (String const &item : items) {
 		if (!check_target_feature_is_valid(pos, item)) {
 			error(pos, "Target feature '%.*s' is not valid", LIT(item));
 			continue;

+ 5 - 8
src/checker.cpp

@@ -256,8 +256,8 @@ gb_internal Scope *create_scope_from_package(CheckerContext *c, AstPackage *pkg)
 	GB_ASSERT(pkg != nullptr);
 
 	isize total_pkg_decl_count = 0;
-	for_array(j, pkg->files) {
-		total_pkg_decl_count += pkg->files.data[j]->total_file_decl_count;
+	for (AstFile *file : pkg->files) {
+		total_pkg_decl_count += file->total_file_decl_count;
 	}
 
 	isize init_elements_capacity = gb_max(DEFAULT_SCOPE_CAPACITY, 2*total_pkg_decl_count);
@@ -692,8 +692,7 @@ gb_internal void check_scope_usage(Checker *c, Scope *scope) {
 
 	gb_sort(vetted_entities.data, vetted_entities.count, gb_size_of(VettedEntity), vetted_entity_variable_pos_cmp);
 
-	for_array(i, vetted_entities) {
-		auto ve = vetted_entities[i];
+	for (auto const &ve : vetted_entities) {
 		Entity *e = ve.entity;
 		Entity *other = ve.other;
 		String name = e->token.string;
@@ -1617,11 +1616,9 @@ gb_internal bool could_entity_be_lazy(Entity *e, DeclInfo *d) {
 		return false;
 	}
 
-	for_array(i, d->attributes) {
-		Ast *attr = d->attributes[i];
+	for (Ast *attr : d->attributes) {
 		if (attr->kind != Ast_Attribute) continue;
-		for_array(j, attr->Attribute.elems) {
-			Ast *elem = attr->Attribute.elems[j];
+		for (Ast *elem : attr->Attribute.elems) {
 			String name = {};
 
 			switch (elem->kind) {