Skip to content

Commit 2c8f479

Browse files
committed
Jsx ppx optimize object allocation
1 parent 8de6c09 commit 2c8f479

6 files changed

+20
-20
lines changed

jscomp/others/jsxPPXReactSupportC.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ module Jsx = JsxC
2626

2727
%%private(
2828
@val
29-
external propsWithKey: (@as(json`{}`) _, 'props, {"key": string}) => 'props = "Object.assign"
29+
external propsWithKey: ({"key": string}, 'props) => 'props = "Object.assign"
3030

3131
@inline
3232
let addKeyProp = (~key: option<string>=?, p: 'props): 'props =>
3333
switch key {
34-
| Some(key) => propsWithKey(p, {"key": key})
34+
| Some(key) => propsWithKey({"key": key}, p)
3535
| None => p
3636
}
3737
)

jscomp/others/jsxPPXReactSupportU.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ module Jsx = JsxU
2626

2727
%%private(
2828
@val
29-
external propsWithKey: (@as(json`{}`) _, 'props, {"key": string}) => 'props = "Object.assign"
29+
external propsWithKey: ({"key": string}, 'props) => 'props = "Object.assign"
3030

3131
@inline
3232
let addKeyProp = (~key: option<string>=?, p: 'props): 'props =>
3333
switch key {
34-
| Some(key) => propsWithKey(p, {"key": key})
34+
| Some(key) => propsWithKey({"key": key}, p)
3535
| None => p
3636
}
3737
)

lib/es6/jsxPPXReactSupportC.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import * as React from "react";
44
import * as Caml_splice_call from "./caml_splice_call.js";
55

66
function createElementWithKey(key, component, props) {
7-
return React.createElement(component, key !== undefined ? Object.assign({}, props, {
7+
return React.createElement(component, key !== undefined ? Object.assign({
88
key: key
9-
}) : props);
9+
}, props) : props);
1010
}
1111

1212
function createElementVariadicWithKey(key, component, props, elements) {
1313
return Caml_splice_call.spliceApply(React.createElement, [
1414
component,
15-
key !== undefined ? Object.assign({}, props, {
15+
key !== undefined ? Object.assign({
1616
key: key
17-
}) : props,
17+
}, props) : props,
1818
elements
1919
]);
2020
}

lib/es6/jsxPPXReactSupportU.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import * as React from "react";
44
import * as Caml_splice_call from "./caml_splice_call.js";
55

66
function createElementWithKey(key, component, props) {
7-
return React.createElement(component, key !== undefined ? Object.assign({}, props, {
7+
return React.createElement(component, key !== undefined ? Object.assign({
88
key: key
9-
}) : props);
9+
}, props) : props);
1010
}
1111

1212
function createElementVariadicWithKey(key, component, props, elements) {
1313
return Caml_splice_call.spliceApply(React.createElement, [
1414
component,
15-
key !== undefined ? Object.assign({}, props, {
15+
key !== undefined ? Object.assign({
1616
key: key
17-
}) : props,
17+
}, props) : props,
1818
elements
1919
]);
2020
}

lib/js/jsxPPXReactSupportC.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ var React = require("react");
44
var Caml_splice_call = require("./caml_splice_call.js");
55

66
function createElementWithKey(key, component, props) {
7-
return React.createElement(component, key !== undefined ? Object.assign({}, props, {
7+
return React.createElement(component, key !== undefined ? Object.assign({
88
key: key
9-
}) : props);
9+
}, props) : props);
1010
}
1111

1212
function createElementVariadicWithKey(key, component, props, elements) {
1313
return Caml_splice_call.spliceApply(React.createElement, [
1414
component,
15-
key !== undefined ? Object.assign({}, props, {
15+
key !== undefined ? Object.assign({
1616
key: key
17-
}) : props,
17+
}, props) : props,
1818
elements
1919
]);
2020
}

lib/js/jsxPPXReactSupportU.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ var React = require("react");
44
var Caml_splice_call = require("./caml_splice_call.js");
55

66
function createElementWithKey(key, component, props) {
7-
return React.createElement(component, key !== undefined ? Object.assign({}, props, {
7+
return React.createElement(component, key !== undefined ? Object.assign({
88
key: key
9-
}) : props);
9+
}, props) : props);
1010
}
1111

1212
function createElementVariadicWithKey(key, component, props, elements) {
1313
return Caml_splice_call.spliceApply(React.createElement, [
1414
component,
15-
key !== undefined ? Object.assign({}, props, {
15+
key !== undefined ? Object.assign({
1616
key: key
17-
}) : props,
17+
}, props) : props,
1818
elements
1919
]);
2020
}

0 commit comments

Comments
 (0)