-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wit, cmd/wit-bindgen-go: WIT tree shaking
This enables WIT tree-shaking by world or interface, as a precursor for Go package-level component metadata. wit/bindgen: oops wit/bindgen: add WIT generation for each WIT interface (Go package) Currently disabled. wit/bindgen: cgo + linker tricks WIP wit: fix typo wit/bindgen: typo wit: type aliases force transitive dependency on the dependencies of their parent interface wit: prepare for filtering interface contents wit: remove ConstrainTo internal/wasm: stub linking section wit/bindgen: generate .wasm.syso files in each Go package Currently stubbed out (if false). Depends on tinygo-org/tinygo#4593 wit: revise package sorting algorithm This enables wasi:http to sort before wasi:cli. wit/bindgen: more cleanup (path -> pkgPath) wit/bindgen: optionally generate WIT files for each Go package cmd/wit-bindgen-go: --generate-wit option to generate WIT files for each Go package wit/bindgen: generate synthetic worlds in the go:bindgen package namespace
- Loading branch information
Showing
32 changed files
with
2,075 additions
and
2,402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package memoize | ||
|
||
// Function memoizes f, caching unique values of k. | ||
// Initial calls to the resulting function will call f(k), then cache and return v. | ||
// Subsequent calls will return the cached value for k. | ||
func Function[F func(K) V, K comparable, V any](f F) F { | ||
m := make(map[K]V) | ||
return func(k K) V { | ||
if v, ok := m[k]; ok { | ||
return v | ||
} | ||
v := f(k) | ||
m[k] = v | ||
return v | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.