From c377d61a2594e1a1c5d431505287cc23d662db98 Mon Sep 17 00:00:00 2001 From: Alex Dik Date: Tue, 8 Mar 2016 11:07:59 +0100 Subject: [PATCH] Remove angular.copy call to enhance performance --- .../api/api-v3/hal/hal-resource.service.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/app/components/api/api-v3/hal/hal-resource.service.ts b/frontend/app/components/api/api-v3/hal/hal-resource.service.ts index fc5a270572..be69c01a15 100644 --- a/frontend/app/components/api/api-v3/hal/hal-resource.service.ts +++ b/frontend/app/components/api/api-v3/hal/hal-resource.service.ts @@ -28,15 +28,16 @@ function halResource(halTransform, HalLink, $q) { return class HalResource { + protected static fromLink(link) { + return new HalResource({_links: {self: link}}, false); + } + public $links; public $embedded; public $isHal: boolean = true; private _name:string; - - protected static fromLink(link) { - return new HalResource({_links: {self: link}}, false); - } + private source:any; public get name():string { return this._name || this.$links.self.$link.title || ''; @@ -47,14 +48,12 @@ function halResource(halTransform, HalLink, $q) { } constructor(protected $source, public $loaded = true) { - var source = angular.copy($source.restangularized ? $source.$plain : $source); + this.source = angular.copy($source.restangularized ? $source.$plain : $source); this.$links = this.transformLinks(); this.$embedded = this.transformEmbedded(); - delete source._links; - delete source._embedded; - angular.extend(this, source); + angular.extend(this, this.source); angular.forEach(this.$links, (link, name:string) => { if (Array.isArray(link)) { @@ -131,7 +130,8 @@ function halResource(halTransform, HalLink, $q) { } private transformHalProperty(propertyName:string, callback:(element) => any) { - var properties = angular.copy(this.$source[propertyName]); + var properties = this.source[propertyName]; + delete this.source[propertyName]; angular.forEach(properties, (property, name) => { properties[name] = callback(property);