Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

perf($parse): Inline constants #14293

Closed
wants to merge 1 commit into from

Conversation

lgalfaso
Copy link
Contributor

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Performance

What is the current behavior? (You can also link to an open issue here)
Constants are not inlined in the function generated by $parse

What is the new behavior (if this is a feature change)?
Constants are inlined in the function generated by $parse

Does this PR introduce a breaking change?
No

Please check if the PR fulfills these requirements

Other information:

Inline constants definitions in function calls, array definitions and object values.

@jbedard
Copy link
Collaborator

jbedard commented Mar 22, 2016

Have an example of how this changes the generated function?

@lgalfaso
Copy link
Contributor Author

For the expression [1, {foo: "bar"}, 1 + 2] it changes it from

// After some reordering and cleanup
var v1 = 1;
var v2 = "bar";
var v3 = {foo: v2};
var v4 = 1;
var v5 = 2;
var v6 = plus(v4, v5);
var v7 = [v1, v3, v6];
return v7;

to

return [1, {foo: "bar"}, plus(1, 2)];

Expression parts that are not constants did not change, and still generate a lot of intermediate variables.

@jbedard
Copy link
Collaborator

jbedard commented Mar 22, 2016

Nice! 😄

@Narretz
Copy link
Contributor

Narretz commented Mar 24, 2016

@lgalfaso Can you put this exampe into the commit message? Makes it easier to grok it later

Inline constants definitions in function calls, array definitions
and object values.

For the expression [1, {foo: "bar"}, 1 + 2] it changes it from

```js
// After some reordering and cleanup
var v1 = 1;
var v2 = "bar";
var v3 = {foo: v2};
var v4 = 1;
var v5 = 2;
var v6 = plus(v4, v5);
var v7 = [v1, v3, v6];
return v7;
```

to

```js
return [1, {foo: "bar"}, plus(1, 2)];
```

Expression parts that are not constants did not change, and still generate a lot
of intermediate variables.
@lgalfaso
Copy link
Contributor Author

Fixed the commit message and landed as bd7d5f6

@lgalfaso lgalfaso closed this Mar 26, 2016
lgalfaso added a commit that referenced this pull request Mar 26, 2016
Inline constants definitions in function calls, array definitions
and object values.

For the expression [1, {foo: "bar"}, 1 + 2] it changes it from

```js
// After some reordering and cleanup
var v1 = 1;
var v2 = "bar";
var v3 = {foo: v2};
var v4 = 1;
var v5 = 2;
var v6 = plus(v4, v5);
var v7 = [v1, v3, v6];
return v7;
```

to

```js
return [1, {foo: "bar"}, plus(1, 2)];
```

Expression parts that are not constants did not change, and still generate a lot
of intermediate variables.

Closes: #14293
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants