Skip to content

Commit

Permalink
refactor(benchpress): remove two mutable exports from largetable/util…
Browse files Browse the repository at this point in the history
….ts (angular#32425)

Mutable exports, i.e. using this pattern

```
export let x = 0;
export function f() {
  x += 1;
}
```

is problematic to transpile to CommonJS and Goog.module systems, we are
working on banning it google internal codebase.

The workaround is adding an explcit getter function.

PR Close angular#32425
  • Loading branch information
rkirov authored and mhevery committed Sep 4, 2019
1 parent 641c5c1 commit f0bdf2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/benchmarks/src/largetable/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class TableCell {
}

let tableCreateCount: number;
export let maxRow: number;
export let maxCol: number;
let maxRow: number;
let maxCol: number;
let numberData: TableCell[][];
let charData: TableCell[][];

Expand Down
6 changes: 3 additions & 3 deletions modules/benchmarks/src/tree/ng2_static/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import {Component, Input, NgModule} from '@angular/core';
import {BrowserModule, DomSanitizer, SafeStyle} from '@angular/platform-browser';

import {TreeNode, emptyTree, maxDepth} from '../util';
import {TreeNode, emptyTree, getMaxDepth} from '../util';

let trustedEmptyColor: SafeStyle;
let trustedGreyColor: SafeStyle;
Expand Down Expand Up @@ -40,8 +40,8 @@ export class RootTreeComponent {

function createModule(): any {
const components: any[] = [RootTreeComponent];
for (let i = 0; i <= maxDepth; i++) {
components.push(createTreeComponent(i, i === maxDepth));
for (let i = 0; i <= getMaxDepth(); i++) {
components.push(createTreeComponent(i, i === getMaxDepth()));
}

@NgModule({imports: [BrowserModule], bootstrap: [RootTreeComponent], declarations: [components]})
Expand Down
8 changes: 6 additions & 2 deletions modules/benchmarks/src/tree/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ export class TreeNode {
}

let treeCreateCount: number;
export let maxDepth: number;
let maxDepth: number;
let numberData: TreeNode;
let charData: TreeNode;

export function getMaxDepth() {
return maxDepth;
}

init();

function init() {
Expand Down Expand Up @@ -77,4 +81,4 @@ export function newArray<T>(size: number, value?: T): T[] {
list.push(value !);
}
return list;
}
}

0 comments on commit f0bdf2a

Please sign in to comment.