浏览代码

Allocate temp array instead of sorting in place

FourteenBrush 2 月之前
父节点
当前提交
64bb0d1c7d
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/check_builtin.cpp

+ 2 - 2
src/check_builtin.cpp

@@ -6941,8 +6941,8 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
 				return false;
 			}
 			
-			// sort enum fields in place in ascending order
-			Array<Entity *> enum_constants = type->Enum.fields;
+			auto enum_constants = array_make<Entity *>(temporary_allocator(), type->Enum.fields.count);
+			array_copy(&enum_constants, type->Enum.fields, 0);
 			array_sort(enum_constants, enum_constant_entity_cmp);
 			
 			BigInt minus_one = big_int_make_i64(-1);