Explorar o código

Replace `x in &y` Use `&v in y` syntax through core & vendor for `switch`/`for` statements

gingerBill %!s(int64=2) %!d(string=hai) anos
pai
achega
3dec55f009

+ 2 - 2
core/container/topological_sort/topological_sort.odin

@@ -32,7 +32,7 @@ init :: proc(sorter: ^$S/Sorter($K)) {
 }
 
 destroy :: proc(sorter: ^$S/Sorter($K)) {
-	for _, v in &sorter.relations {
+	for _, v in sorter.relations {
 		delete(v.dependents)
 	}
 	delete(sorter.relations)
@@ -80,7 +80,7 @@ sort :: proc(sorter: ^$S/Sorter($K)) -> (sorted, cycled: [dynamic]K) {
 		}
 	}
 
-	for root in &sorted do for k, _ in relations[root].dependents {
+	for root in sorted do for k, _ in relations[root].dependents {
 		relation := &relations[k]
 		relation.dependencies -= 1
 		if relation.dependencies == 0 {

+ 2 - 2
core/encoding/hxa/read.odin

@@ -83,7 +83,7 @@ read :: proc(data: []byte, filename := "<input>", print_error := false, allocato
 		meta_data = make([]Meta, int(capacity))
 		count := 0
 		defer meta_data = meta_data[:count]
-		for m in &meta_data {
+		for &m in meta_data {
 			m.name = read_name(r) or_return
 
 			type := read_value(r, Meta_Value_Type) or_return
@@ -116,7 +116,7 @@ read :: proc(data: []byte, filename := "<input>", print_error := false, allocato
 		layer_count := 0
 		layers = make(Layer_Stack, stack_count)
 		defer layers = layers[:layer_count]
-		for layer in &layers {
+		for &layer in layers {
 			layer.name = read_name(r) or_return
 			layer.components = read_value(r, u8) or_return
 			type := read_value(r, Layer_Data_Type) or_return

+ 5 - 5
core/encoding/json/unmarshal.odin

@@ -72,7 +72,7 @@ unmarshal_string :: proc(data: string, ptr: ^$T, spec := DEFAULT_SPECIFICATION,
 @(private)
 assign_bool :: proc(val: any, b: bool) -> bool {
 	v := reflect.any_core(val)
-	switch dst in &v {
+	switch &dst in v {
 	case bool: dst = bool(b)
 	case b8:   dst = b8  (b)
 	case b16:  dst = b16 (b)
@@ -85,7 +85,7 @@ assign_bool :: proc(val: any, b: bool) -> bool {
 @(private)
 assign_int :: proc(val: any, i: $T) -> bool {
 	v := reflect.any_core(val)
-	switch dst in &v {
+	switch &dst in v {
 	case i8:      dst = i8     (i)
 	case i16:     dst = i16    (i)
 	case i16le:   dst = i16le  (i)
@@ -122,7 +122,7 @@ assign_int :: proc(val: any, i: $T) -> bool {
 @(private)
 assign_float :: proc(val: any, f: $T) -> bool {
 	v := reflect.any_core(val)
-	switch dst in &v {
+	switch &dst in v {
 	case f16:     dst = f16  (f)
 	case f16le:   dst = f16le(f)
 	case f16be:   dst = f16be(f)
@@ -150,7 +150,7 @@ assign_float :: proc(val: any, f: $T) -> bool {
 @(private)
 unmarshal_string_token :: proc(p: ^Parser, val: any, str: string, ti: ^reflect.Type_Info) -> bool {
 	val := val
-	switch dst in &val {
+	switch &dst in val {
 	case string:
 		dst = str
 		return true
@@ -215,7 +215,7 @@ unmarshal_value :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) {
 		}
 	}
 	
-	switch dst in &v {
+	switch &dst in v {
 	// Handle json.Value as an unknown type
 	case Value:
 		dst = parse_value(p) or_return

+ 6 - 6
core/image/netpbm/netpbm.odin

@@ -161,18 +161,18 @@ save_to_buffer :: proc(img: ^Image, custom_info: Info = {}, allocator := context
 		// convert from native endianness
 		if img.depth == 16 {
 			pixels := mem.slice_data_cast([]u16be, data.buf[len(header_buf):])
-			for p in &pixels {
+			for &p in pixels {
 				p = u16be(transmute(u16) p)
 			}
 		} else if header.format in PFM {
 			if header.little_endian {
 				pixels := mem.slice_data_cast([]f32le, data.buf[len(header_buf):])
-				for p in &pixels {
+				for &p in pixels {
 					p = f32le(transmute(f32) p)
 				}
 			} else {
 				pixels := mem.slice_data_cast([]f32be, data.buf[len(header_buf):])
-				for p in &pixels {
+				for &p in pixels {
 					p = f32be(transmute(f32) p)
 				}
 			}
@@ -578,18 +578,18 @@ decode_image :: proc(img: ^Image, header: Header, data: []byte, allocator := con
 		if header.format in PFM {
 			pixels := mem.slice_data_cast([]f32, img.pixels.buf[:])
 			if header.little_endian {
-				for p in &pixels {
+				for &p in pixels {
 					p = f32(transmute(f32le) p)
 				}
 			} else {
-				for p in &pixels {
+				for &p in pixels {
 					p = f32(transmute(f32be) p)
 				}
 			}
 		} else {
 			if img.depth == 16 {
 				pixels := mem.slice_data_cast([]u16, img.pixels.buf[:])
-				for p in &pixels {
+				for &p in pixels {
 					p = u16(transmute(u16be) p)
 				}
 			}

+ 1 - 1
core/image/png/helpers.odin

@@ -36,7 +36,7 @@ destroy :: proc(img: ^Image) {
 	bytes.buffer_destroy(&img.pixels)
 
 	if v, ok := img.metadata.(^image.PNG_Info); ok {
-		for chunk in &v.chunks {
+		for chunk in v.chunks {
 			delete(chunk.data)
 		}
 		delete(v.chunks)

+ 3 - 3
core/math/big/helpers.odin

@@ -19,7 +19,7 @@ import rnd "core:math/rand"
 int_destroy :: proc(integers: ..^Int) {
 	integers := integers
 
-	for a in &integers {
+	for a in integers {
 		assert_if_nil(a)
 	}
 	#force_inline internal_int_destroy(..integers)
@@ -408,7 +408,7 @@ clear_if_uninitialized_multi :: proc(args: ..^Int, allocator := context.allocato
 	args := args
 	assert_if_nil(..args)
 
-	for i in &args {
+	for i in args {
 		#force_inline internal_clear_if_uninitialized_single(i, allocator) or_return
 	}
 	return err
@@ -435,7 +435,7 @@ int_init_multi :: proc(integers: ..^Int, allocator := context.allocator) -> (err
 	assert_if_nil(..integers)
 
 	integers := integers
-	for a in &integers {
+	for a in integers {
 		#force_inline internal_clear(a, true, allocator) or_return
 	}
 	return nil

+ 2 - 2
core/math/big/internal.odin

@@ -1857,7 +1857,7 @@ internal_root_n :: proc { internal_int_root_n, }
 internal_int_destroy :: proc(integers: ..^Int) {
 	integers := integers
 
-	for a in &integers {
+	for &a in integers {
 		if internal_int_allocated_cap(a) > 0 {
 			mem.zero_slice(a.digit[:])
 			free(&a.digit[0])
@@ -2909,7 +2909,7 @@ internal_int_init_multi :: proc(integers: ..^Int, allocator := context.allocator
 	context.allocator = allocator
 
 	integers := integers
-	for a in &integers {
+	for a in integers {
 		internal_clear(a) or_return
 	}
 	return nil

+ 1 - 1
core/math/big/rat.odin

@@ -137,7 +137,7 @@ rat_copy :: proc(dst, src: ^Rat, minimize := false, allocator := context.allocat
 internal_rat_destroy :: proc(rationals: ..^Rat) {
 	rationals := rationals
 
-	for z in &rationals {
+	for &z in rationals {
 		internal_int_destroy(&z.a, &z.b)
 	}
 }

+ 1 - 1
core/math/ease/ease.odin

@@ -450,7 +450,7 @@ flux_tween_init :: proc(tween: ^Flux_Tween($T), duration: time.Duration) where i
 flux_update :: proc(flux: ^Flux_Map($T), dt: f64) where intrinsics.type_is_float(T) {
 	clear(&flux.keys_to_be_deleted)
 
-	for key, tween in &flux.values {
+	for key, &tween in flux.values {
 		delay_remainder := f64(0)
 
 		// Update delay if necessary.

+ 2 - 2
core/reflect/reflect.odin

@@ -781,7 +781,7 @@ set_union_variant_raw_tag :: proc(a: any, tag: i64) {
 		tag_ptr := uintptr(a.data) + info.tag_offset
 		tag_any := any{rawptr(tag_ptr), info.tag_type.id}
 
-		switch i in &tag_any {
+		switch &i in tag_any {
 		case u8:   i = u8(tag)
 		case i8:   i = i8(tag)
 		case u16:  i = u16(tag)
@@ -1312,7 +1312,7 @@ relative_pointer_to_absolute_raw :: proc(data: rawptr, base_integer_id: typeid)
 
 	ptr_any := any{data, base_integer_id}
 	ptr: rawptr
-	switch i in &ptr_any {
+	switch &i in ptr_any {
 	case u8:    ptr = _handle(&i)
 	case u16:   ptr = _handle(&i)
 	case u32:   ptr = _handle(&i)

+ 4 - 4
core/strings/strings.odin

@@ -1194,7 +1194,7 @@ Output:
 split_lines :: proc(s: string, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error {
 	sep :: "\n"
 	lines := _split(s, sep, 0, -1, allocator) or_return
-	for line in &lines {
+	for &line in lines {
 		line = _trim_cr(line)
 	}
 	return lines, nil
@@ -1234,7 +1234,7 @@ Output:
 split_lines_n :: proc(s: string, n: int, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error {
 	sep :: "\n"
 	lines := _split(s, sep, 0, n, allocator) or_return
-	for line in &lines {
+	for &line in lines {
 		line = _trim_cr(line)
 	}
 	return lines, nil
@@ -1273,7 +1273,7 @@ Output:
 split_lines_after :: proc(s: string, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error {
 	sep :: "\n"
 	lines := _split(s, sep, len(sep), -1, allocator) or_return
-	for line in &lines {
+	for &line in lines {
 		line = _trim_cr(line)
 	}
 	return lines, nil
@@ -1314,7 +1314,7 @@ Output:
 split_lines_after_n :: proc(s: string, n: int, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error {
 	sep :: "\n"
 	lines := _split(s, sep, len(sep), n, allocator) or_return
-	for line in &lines {
+	for &line in lines {
 		line = _trim_cr(line)
 	}
 	return lines, nil

+ 2 - 2
core/text/i18n/i18n.odin

@@ -170,8 +170,8 @@ destroy :: proc(catalog: ^Translation = ACTIVE, allocator := context.allocator)
 		return
 	}
 
-	for section in &catalog.k_v {
-		for key in &catalog.k_v[section] {
+	for section in catalog.k_v {
+		for key in catalog.k_v[section] {
 			delete(catalog.k_v[section][key])
 		}
 		delete(catalog.k_v[section])

+ 1 - 1
core/thread/thread_pool.odin

@@ -81,7 +81,7 @@ pool_destroy :: proc(pool: ^Pool) {
 	delete(pool.tasks)
 	delete(pool.tasks_done)
 
-	for t in &pool.threads {
+	for &t in pool.threads {
 		destroy(t)
 	}
 

+ 1 - 1
core/unicode/tools/generate_entity_table.odin

@@ -221,7 +221,7 @@ named_xml_entity_to_rune :: proc(name: string) -> (decoded: rune, ok: bool) {
 
 	delete(entity_map)
 	delete(names)
-	for name in &names {
+	for &name in names {
 		free(&name)
 	}
 }