From 6534ffea26bc97ca8d0f59aa21983e6fd0af5720 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 10 May 2016 14:55:19 +0200 Subject: [PATCH] perf(objects): memoize () => this._pool --- packages/xen-api/src/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/xen-api/src/index.js b/packages/xen-api/src/index.js index a6354f7d4..20b9c82b8 100644 --- a/packages/xen-api/src/index.js +++ b/packages/xen-api/src/index.js @@ -253,10 +253,13 @@ export class Xapi extends EventEmitter { this.on('connected', this._watchEvents) this.on('disconnected', () => { this._fromToken = '' - objects.clear() + // objects.clear() }) this._readOnly = Boolean(opts.readOnly) + + // Memoize this function _addObject(). + this._getPool = () => this._pool } get readOnly () { @@ -557,7 +560,7 @@ export class Xapi extends EventEmitter { // All custom properties are read-only and non enumerable. defineProperties(object, { $id: { value: object.uuid || ref }, - $pool: { get: () => this._pool }, + $pool: { get: this._getPool }, $ref: { value: ref }, $type: { value: type } })