Skip to content

Commit

Permalink
fix(core): remove duplicated noop function (#39761)
Browse files Browse the repository at this point in the history
The codebase currently contains several `noop` functions,
and they can end up in the bundle of an application.
A recent commit 6fbe219 tipped us off
as it introduced several `noop` occurrences in the golden symbol files.
After investigating with @petebacondarwin,
we decided to remove the duplicated functions.

This probably shaves only a few bytes,
but this commit removes the duplicated functions,
by always using the one in `core/src/utils/noop`.

PR Close #39761
  • Loading branch information
cexbrayat authored and AndrewKushnir committed Nov 19, 2020
1 parent 935cf43 commit 066126a
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 10 deletions.
2 changes: 0 additions & 2 deletions packages/compiler/src/render3/view/util.ts
Expand Up @@ -142,8 +142,6 @@ export function getQueryPredicate(
}
}

export function noop() {}

export class DefinitionMap {
values: {key: string, quoted: boolean, value: o.Expression}[] = [];

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/zone/ng_zone.ts
Expand Up @@ -8,6 +8,7 @@

import {EventEmitter} from '../event_emitter';
import {global} from '../util/global';
import {noop} from '../util/noop';
import {getNativeRequestAnimationFrame} from '../util/raf';


Expand Down Expand Up @@ -231,7 +232,6 @@ export class NgZone {
}
}

function noop() {}
const EMPTY_PAYLOAD = {};

interface NgZonePrivate extends NgZone {
Expand Down
3 changes: 0 additions & 3 deletions packages/core/test/bundling/forms/bundle.golden_symbols.json
Expand Up @@ -1397,9 +1397,6 @@
{
"name": "noop"
},
{
"name": "noop"
},
{
"name": "normalizeValidators"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/core/test/bundling/router/bundle.golden_symbols.json
Expand Up @@ -1721,9 +1721,6 @@
{
"name": "noop"
},
{
"name": "noop"
},
{
"name": "normalizeQueryParams"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/render3/render_util.ts
Expand Up @@ -18,6 +18,7 @@ import {TConstants, TNodeType} from '@angular/core/src/render3/interfaces/node';
import {RComment, RElement, RNode, RText} from '@angular/core/src/render3/interfaces/renderer_dom';
import {enterView, getLView} from '@angular/core/src/render3/state';
import {EMPTY_ARRAY} from '@angular/core/src/util/empty';
import {noop} from '@angular/core/src/util/noop';
import {stringifyElement} from '@angular/platform-browser/testing/src/browser_util';

import {SWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__ as R3_CHANGE_DETECTOR_REF_FACTORY} from '../../src/change_detection/change_detector_ref';
Expand Down Expand Up @@ -85,7 +86,6 @@ export abstract class BaseFixture {
}
}

function noop() {}
/**
* Fixture for testing template functions in a convenient way.
*
Expand Down

0 comments on commit 066126a

Please sign in to comment.