From 74f662e1f03a00a4609adbad69b0a019ecef3bb3 Mon Sep 17 00:00:00 2001 From: kartikdutt18 Date: Sat, 18 Apr 2020 09:05:43 +0530 Subject: [PATCH] fix clean up of move copy constructor Move ampersand to the left to match the codebase --- src/mlpack/methods/lars/lars.cpp | 14 -------------- src/mlpack/methods/lars/lars.hpp | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/mlpack/methods/lars/lars.cpp b/src/mlpack/methods/lars/lars.cpp index df0ce98f45..efbc471d83 100644 --- a/src/mlpack/methods/lars/lars.cpp +++ b/src/mlpack/methods/lars/lars.cpp @@ -109,9 +109,6 @@ LARS::LARS(LARS&& other) : { // Clean the other object to prevent to objects pointing // at the memory location. - if (other.matGram) - delete other.matGram; - other.matGram = new arma::mat(other.matGramInternal); other.lambda1 = 0.0; other.lambda2 = 0.0; @@ -123,10 +120,6 @@ LARS& LARS::operator=(const LARS& other) if (&other == this) return *this; - // Clean the memory first. - if (matGram) - delete matGram; - matGramInternal = other.matGramInternal; matGram = &matGramInternal; matUtriCholFactor = other.matUtriCholFactor; @@ -151,10 +144,6 @@ LARS& LARS::operator=(LARS&& other) if (&other == this) return *this; - // Clean the memory first. - if (matGram) - delete matGram; - matGramInternal = std::move(other.matGramInternal); matGram = other.matGram; matUtriCholFactor = std::move(other.matUtriCholFactor); @@ -173,9 +162,6 @@ LARS& LARS::operator=(LARS&& other) // Clean the other object to prevent to objects pointing // at the memory location. - if (other.matGram) - delete other.matGram; - other.matGram = new arma::mat(other.matGramInternal); other.lambda1 = 0.0; other.lambda2 = 0.0; diff --git a/src/mlpack/methods/lars/lars.hpp b/src/mlpack/methods/lars/lars.hpp index da3de1fdfd..71fcd116bc 100644 --- a/src/mlpack/methods/lars/lars.hpp +++ b/src/mlpack/methods/lars/lars.hpp @@ -189,14 +189,14 @@ class LARS * * @param other LARS object to copy. */ - LARS &operator=(const LARS& other); + LARS& operator=(const LARS& other); /** * Take ownership of the given LARS object. * * @param other LARS object to take ownership of. */ - LARS &operator=(LARS&& other); + LARS& operator=(LARS&& other); /** * Run LARS. The input matrix (like all mlpack matrices) should be