Convert four variable assignments to the usage of combined operators
elfring opened this issue Β· comments
π Some source code analysis tools can help to find opportunities for improving software components.
π I propose to increase the usage of combined operators accordingly.
diff --git a/Protocols/EPP/eppConnection.php b/Protocols/EPP/eppConnection.php
index 1c5fdf2..3076bac 100755
--- a/Protocols/EPP/eppConnection.php
+++ b/Protocols/EPP/eppConnection.php
@@ -555,7 +555,7 @@ class eppConnection {
while ($readLength > 0) {
// $loops++;
if ($readbuffer = fread($this->connection, $readLength)) {
- $readLength = $readLength - strlen($readbuffer);
+ $readLength -= strlen($readbuffer);
$read .= $readbuffer;
$time = time() + $this->timeout;
} elseif ($useSleep) {
@@ -588,7 +588,7 @@ class eppConnection {
$time = time() + $this->timeout;
if ($read = fread($this->connection, $length)) {
//$this->writeLog(print_R(socket_get_status($this->connection), true));
- $length = $length - strlen($read);
+ $length -= strlen($read);
$content .= $read;
$time = time() + $this->timeout;
}
diff --git a/Tests/lvEppContactExtTest.php b/Tests/lvEppContactExtTest.php
index f1c3021..14c3839 100644
--- a/Tests/lvEppContactExtTest.php
+++ b/Tests/lvEppContactExtTest.php
@@ -198,7 +198,7 @@ class lvEppContactExtTest extends eppTestCase {
}
// success
- $startpos = $startpos + strlen($start);
+ $startpos += strlen($start);
$length = $endpos - $startpos;
$text = substr($text, $startpos, $length);
diff --git a/Tests/lvEppDomainExtTest.php b/Tests/lvEppDomainExtTest.php
index f3516eb..436f11b 100644
--- a/Tests/lvEppDomainExtTest.php
+++ b/Tests/lvEppDomainExtTest.php
@@ -196,7 +196,7 @@ class lvEppDomainExtTest extends eppTestCase {
}
// success
- $startpos = $startpos + strlen($start);
+ $startpos += strlen($start);
$length = $endpos - $startpos;
$text = substr($text, $startpos, $length);
π I would appreciate a more constructive feedback for the shown change possibility.
Well, from a programming perspective there is no difference between $c = $c +1 and $c += 1;
The resulting execution code and performance will be exactly the same.
It is just a matter of taste. Some will like the first, some will like the second. Everyone has their reasons.
The resulting execution code and performance will be exactly the same.
π I suggest to reconsider this development view.
π I got the impression that the usage of combined operators for in-place modifications can influence the software run time characteristics in desirable directions.