Skip to content

Commit 7973c84

Browse files
authored
feat(typia): performance optimization. (#1851)
* feat(typia): performance optimization. * bump up ttsc * publish next version
1 parent f8c08ef commit 7973c84

30 files changed

Lines changed: 874 additions & 756 deletions

File tree

benchmark/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@typia/benchmark",
4-
"version": "13.0.0-dev.20260511",
4+
"version": "13.0.0-dev.20260514",
55
"description": "Benchmark program of typia performance",
66
"main": "bin/index.js",
77
"scripts": {

config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@typia/config",
4-
"version": "13.0.0-dev.20260511",
4+
"version": "13.0.0-dev.20260514",
55
"description": "Shared build configuration for typia packages",
66
"devDependencies": {
77
"@rollup/plugin-commonjs": "catalog:rollup",

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@typia/examples",
4-
"version": "13.0.0-dev.20260511",
4+
"version": "13.0.0-dev.20260514",
55
"description": "Example codes for typia website",
66
"scripts": {
77
"build": "rimraf bin && ttsc && prettier --write --ignore-path /dev/null \"bin/**/*.js\"",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@typia/station",
4-
"version": "13.0.0-dev.20260511",
4+
"version": "13.0.0-dev.20260514",
55
"description": "Typia Station",
66
"scripts": {
77
"build": "pnpm run build:packages",

packages/interface/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typia/interface",
3-
"version": "13.0.0-dev.20260511",
3+
"version": "13.0.0-dev.20260514",
44
"description": "Superfast runtime validators with only one line",
55
"main": "src/index.ts",
66
"types": "src/index.ts",

packages/langchain/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typia/langchain",
3-
"version": "13.0.0-dev.20260511",
3+
"version": "13.0.0-dev.20260514",
44
"description": "LangChain.js integration for typia",
55
"main": "src/index.ts",
66
"exports": {

packages/mcp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typia/mcp",
3-
"version": "13.0.0-dev.20260511",
3+
"version": "13.0.0-dev.20260514",
44
"description": "MCP (Model Context Protocol) integration for typia",
55
"main": "src/index.ts",
66
"exports": {

packages/typia/native/adapter/adapter.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,20 @@ func emitCallWithOptions(program *driver.Program, site CallSite, plugin PluginOp
7979
}
8080
}
8181
}()
82-
node := nativetransform.CallExpressionTransformer.Transform(nativetransform.CallExpressionTransformer_TransformProps{
83-
Context: context,
84-
Expression: site.Call,
85-
})
82+
var node *shimast.Node
83+
if site.Module != "" && site.Method != "" {
84+
node = nativetransform.CallExpressionTransformer.TransformKnown(nativetransform.CallExpressionTransformer_TransformKnownProps{
85+
Context: context,
86+
Expression: site.Call,
87+
Module: site.Module,
88+
Method: site.Method,
89+
})
90+
} else {
91+
node = nativetransform.CallExpressionTransformer.Transform(nativetransform.CallExpressionTransformer_TransformProps{
92+
Context: context,
93+
Expression: site.Call,
94+
})
95+
}
8696
if node == nil || node == site.Call.AsNode() {
8797
return "", false, nil
8898
}

packages/typia/native/adapter/imports.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,25 @@ import (
44
"path/filepath"
55
"strconv"
66
"strings"
7+
"sync"
78
"unicode"
89

910
shimast "github.com/microsoft/typescript-go/shim/ast"
1011
)
1112

13+
type commonJSImportIdentifierSubstitutionsCacheEntry struct {
14+
value map[string]string
15+
}
16+
17+
var commonJSImportIdentifierSubstitutionsCache sync.Map
18+
1219
func commonJSImportIdentifierSubstitutions(file *shimast.SourceFile) map[string]string {
1320
if file == nil || file.Statements == nil {
1421
return nil
1522
}
23+
if cached, ok := commonJSImportIdentifierSubstitutionsCache.Load(file); ok {
24+
return cached.(commonJSImportIdentifierSubstitutionsCacheEntry).value
25+
}
1626
output := map[string]string{}
1727
counts := map[string]int{}
1828
for _, stmt := range file.Statements.Nodes {
@@ -61,8 +71,9 @@ func commonJSImportIdentifierSubstitutions(file *shimast.SourceFile) map[string]
6171
}
6272
}
6373
if len(output) == 0 {
64-
return nil
74+
output = nil
6575
}
76+
commonJSImportIdentifierSubstitutionsCache.Store(file, commonJSImportIdentifierSubstitutionsCacheEntry{value: output})
6677
return output
6778
}
6879

0 commit comments

Comments
 (0)