From 7e3fdb45058597cc9737fd5fb79c28b0515fa6db Mon Sep 17 00:00:00 2001 From: vakrilov Date: Fri, 12 May 2017 17:22:00 +0300 Subject: [PATCH] Fixes --- tns-core-modules/profiling/profiling.d.ts | 2 +- tns-core-modules/profiling/profiling.ts | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tns-core-modules/profiling/profiling.d.ts b/tns-core-modules/profiling/profiling.d.ts index 9c0e7c0af..d6e7603e6 100644 --- a/tns-core-modules/profiling/profiling.d.ts +++ b/tns-core-modules/profiling/profiling.d.ts @@ -53,7 +53,7 @@ export declare function stop(name: string): TimerInfo; * Works only if profiling is enabled. * @param name Name of the timer which will be used for method calls. If not provided - the name of the method will be used. */ -export declare function profile(name?: string): (target, key, descriptor) => void; +export declare function profile(name?: string): MethodDecorator; /** * Prints the timer for all methods instrumented with profile decorator. diff --git a/tns-core-modules/profiling/profiling.ts b/tns-core-modules/profiling/profiling.ts index 9df4a6185..64ba4a8ab 100644 --- a/tns-core-modules/profiling/profiling.ts +++ b/tns-core-modules/profiling/profiling.ts @@ -49,9 +49,8 @@ export function start(name: string): void { return; } - let info: TimerInfo; - if (timers.has(name)) { - info = timers.get(name); + let info = timers.get(name); + if (info) { if (info.isRunning) { throw new Error(`Timer already running: ${name}`); } @@ -107,11 +106,10 @@ function pauseInternal(name: string): TimerInfo { return info; } -export function profile(name?: string): (target, key, descriptor) => void { +export function profile(name?: string): MethodDecorator { return (target, key, descriptor) => { if (!ENABLED) { - // Return the original descriptor if not enabled - return descriptor; + return; } // save a reference to the original method this way we keep the values currently in the