Browse Source

Delete more unnecessary validations (#5055)

in while()
Joan Miquel 6 years ago
parent
commit
5f445ddb70

+ 1 - 1
frameworks/PHP/hamlet/Benchmark/Resources/QueriesResource.php

@@ -32,7 +32,7 @@ class QueriesResource extends DbResource
         $count = $this->getQueriesCount($request);
 
         $payload = [];
-        while ($count-- > 0) {
+        while ($count--) {
             $id = mt_rand(1, 10000);
             $this->procedure->bindInteger($id);
             $payload[] = $this->procedure->processOne()

+ 1 - 1
frameworks/PHP/hamlet/Benchmark/Resources/UpdateResource.php

@@ -41,7 +41,7 @@ class UpdateResource extends DbResource
         $count = $this->getQueriesCount($request);
 
         $payload = [];
-        while ($count-- > 0) {
+        while ($count--) {
             $id = mt_rand(1, 10000);
             $randomNumber = mt_rand(1, 10000);
 

+ 1 - 1
frameworks/PHP/peachpie/Website/dbraw.php

@@ -25,7 +25,7 @@ function dbraw() {
   $id = mt_rand(1, 10000);
 
   // For each query, store the result set values in the response array
-  while (0 < $query_count--) {
+  while ($query_count--) {
     $result = mysql_query("SELECT randomNumber FROM World WHERE id = $id", $link);
 
     // Store result in array.

+ 1 - 1
frameworks/PHP/peachpie/Website/updateraw.php

@@ -25,7 +25,7 @@ function updateraw() {
   $randomNumber = mt_rand(1, 1000);
 
   // For each query, store the result set values in the response array
-  while (0 < $query_count--) {
+  while ($query_count--) {
     $result = mysql_query("SELECT randomNumber FROM World WHERE id = $id", $link);
     
     // Store result in array.

+ 2 - 2
frameworks/PHP/swoole/swoole-server.php

@@ -33,7 +33,7 @@ $db = function (string $database_type, int $queries = 0) use ($pool): string {
     $db->db_test = $db->db_test ?? $db->prepare('SELECT randomNumber FROM World WHERE id = ?');
 
     // For each query, store the result set values in the response array
-    while (0 < $query_count--) {
+    while ($query_count--) {
         $id = mt_rand(1, 10000);
         $ret = $db->db_test->execute([$id]);
 
@@ -104,7 +104,7 @@ $updates = function (string $database_type, int $queries = 0) use ($pool): strin
     $db->updates_test_select = $db->updates_test_select ?? $db->prepare('SELECT randomNumber FROM World WHERE id = ?');
     $db->updates_test_update = $db->updates_test_update ?? $db->prepare('UPDATE World SET randomNumber = ? WHERE id = ?');
 
-    while (0 < $query_count--) {
+    while ($query_count--) {
         $id = mt_rand(1, 10000);
         $randomNumber = mt_rand(1, 10000);
         $ret = $db->updates_test_select->execute([$id]);

+ 2 - 2
frameworks/PHP/yii2/app/controllers/RawController.php

@@ -31,7 +31,7 @@ class RawController extends Controller
         $statement = Yii::$app->db->createCommand('SELECT id, randomNumber FROM World WHERE id = :id');
 
         $worlds = [];
-        while (0 < $queries--) {
+        while ($queries--) {
             $result = $statement->bindValue(':id', mt_rand(1, 10000))->queryOne();
             $result['id'] = (int)$result['id'];
             $result['randomNumber'] = (int)$result['randomNumber'];
@@ -70,7 +70,7 @@ class RawController extends Controller
 
         $worlds = [];
 
-        while (0 < $queries--) {
+        while ($queries--) {
             $id = mt_rand(1, 10000);
             $randomNumber = mt_rand(1, 1000);
             $selectCommand->bindParam(':id', $id)->queryScalar();

+ 2 - 2
frameworks/PHP/yii2/app/controllers/SiteController.php

@@ -36,7 +36,7 @@ class SiteController extends Controller
 
         $worlds = [];
 
-        while (0 < $queries--) {
+        while ($queries--) {
             $world = World::findOne(random_int(1, 10000));
             $worlds[] = $world;
         }
@@ -75,7 +75,7 @@ class SiteController extends Controller
 
         $worlds = [];
 
-        while (0 < $queries--) {
+        while ($queries--) {
             $world = World::findOne(random_int(1, 10000));
             $world->randomNumber = random_int(1, 10000);
             $world->save();