blueloveTH před 3 roky
rodič
revize
b7e45ac2d2
2 změnil soubory, kde provedl 11 přidání a 17 odebrání
  1. 6 10
      src/memory.h
  2. 5 7
      src/safestl.h

+ 6 - 10
src/memory.h

@@ -41,20 +41,16 @@ namespace pkpy{
         }
 
         shared_ptr& operator=(const shared_ptr& other) {
-            if (this != &other) {
-                _dec_counter();
-                counter = other.counter;
-                _inc_counter();
-            }
+            _dec_counter();
+            counter = other.counter;
+            _inc_counter();
             return *this;
         }
 
         shared_ptr& operator=(shared_ptr&& other) noexcept {
-            if (this != &other) {
-                _dec_counter();
-                counter = other.counter;
-                other.counter = nullptr;
-            }
+            _dec_counter();
+            counter = other.counter;
+            other.counter = nullptr;
             return *this;
         }
 

+ 5 - 7
src/safestl.h

@@ -99,13 +99,11 @@ namespace pkpy {
         const PyVar& operator[](uint8_t i) const { return _args[i]; }
 
         ArgList& operator=(ArgList&& other) noexcept {
-            if(this != &other){
-                __tryRelease();
-                this->_args = other._args;
-                this->_size = other._size;
-                other._args = nullptr;
-                other._size = 0;
-            }
+            __tryRelease();
+            this->_args = other._args;
+            this->_size = other._size;
+            other._args = nullptr;
+            other._size = 0;
             return *this;
         }