pulumi/pkg/codegen/hcl2/model
Fraser Waters 571fadae3f Use slice.Prealloc instead of make([]T, 0, ...)
Fixes https://github.com/pulumi/pulumi/issues/12738

https://github.com/pulumi/pulumi/pull/11834 turned on the prealloc
linter and changed a load of slice uses from just `var x T[]` to `x :=
make([]T, 0, preallocSize)`. This was good for performance but it turns
out there are a number of places in the codebase that treat a `nil`
slice as semnatically different to an empty slice.

Trying to test that, or even reason that through for every callsite is
untractable, so this PR replaces all expressions of the form `make([]T,
0, size)` with a call to `slice.Prealloc[T](size)`. When size is 0 that
returns a nil array, rather than an empty array.
2023-06-29 11:27:50 +01:00
..
format all: Assert => Assertf 2023-03-03 14:37:43 -08:00
pretty Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
attribute.go Do not panic when PCL attribute type or PCL resource variable type isn't fully bound 2023-04-12 18:19:57 +02:00
binder_expression.go refactor GetCollection to unwrap the iterable source type in it 2023-04-24 17:01:01 +02:00
binder_expression_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
block.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
body.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
diagnostics.go Handle recursive types 2023-01-13 11:28:13 -08:00
expression.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
functions.go Initial implementation of simplified invokes for dotnet and nodejs 2023-01-11 14:17:14 -08:00
print_test.go Escape `${` & `%{` in string literals 2022-12-08 10:46:23 +01:00
printer.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
scope.go Regen TypeScript examples 2023-06-07 10:54:25 +02:00
spec.md Add an HCL2 static typechecker and semantic model. (#4087) 2020-03-18 09:28:57 -07:00
traversable.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
type.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_collection.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
type_const.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_enum.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_eventuals.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
type_list.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_map.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_none.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_object.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
type_opaque.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_opaque_test.go [codegen] simplify opaque types to string newtype (#9770) 2022-06-13 11:13:03 -07:00
type_output.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_promise.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_scope.go Support map(any) in config/output types 2023-04-06 21:15:20 +01:00
type_set.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_test.go Allow case insensitive prop typecheck on traversal 2022-11-08 09:08:12 -08:00
type_tuple.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
type_union.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
type_union_test.go Fix stack overflow panic when pretty printing recursive types 2023-05-11 16:28:16 +02:00
utilities.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
visitor.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00