Commit Graph

9 Commits

Author SHA1 Message Date
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
Robbie McKinstry 4959522a53
Repair tests expecting nil slices 2023-01-11 21:53:04 -08:00
Robbie McKinstry 1f78baae71
Preallocate slices with a known capacity.
Enable the prealloc linter, which identifies slices
with a known capacity, but are not preallocated, which
results in unnecessary allocations and memcpys.
2023-01-11 12:52:51 -08:00
Ian Wahbe 65b6b01abd Don't use *schema.Package in python codegen 2022-12-07 17:54:38 +01:00
Aaron Friel a4b1d6b2a7 ci: gofmt 1.18+ clean 2022-09-21 09:48:39 -07:00
Levi Blackstone 0d4fb3e340
[schema] Add IsOverlay option to disable codegen for particular types ()
Add a new `IsOverlay` option to schema types and functions that allows providers to document overlays in the schema. This makes it easier to generate API docs consistently, even for code that is generated outside of the typical codegen process.
2021-11-11 17:00:03 -07:00
Anton Tayanovskyy 49ccd9ac97
Simplify output-funcs codegen test ()
* Consolidate output-funcs into a single normal schema.json

* Accept nodejs codegen output

* Accept dotnet output-funcs output; does not compile yet

* Accept docs output-funcs output

* Permit parallel test runs

* Accept nodejs codegen

* Fix and speed up Python codegen tests

* Dedup dash-named-schema

* Make dotnet tests pass

* Satisfy go lint
2021-09-23 13:42:20 -04:00
Anton Tayanovskyy 85142462c7
Fix non-deterministic ordering of generated Python code ()
* Fix non-deterministic ordering of generated Python code

* Repro the problem in a test and fix it; address comments

* Lint
2021-05-26 13:22:05 -04:00
Anton Tayanovskyy 6f1ea08993
Import subpackages lazily ()
* Import subpackages lazily

* Tighten up lazy_import impl

* Eagerly register resources, but lazily load their impl

* Add CHANGELOG entry

* Satisfy lint

* Restore mypy behavior so the change is not breaking

* Fix golden tests
2021-04-29 16:08:22 -04:00