Remove angular.copy call to enhance performance

pull/4159/head
Alex Dik 9 years ago
parent ac9d7f0574
commit c377d61a25
  1. 18
      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);

Loading…
Cancel
Save