[Bf-blender-cvs] [62b50c612f6] master: Cleanup: Else after return, other simplifications

Hans Goudey noreply at git.blender.org
Tue Nov 23 18:49:55 CET 2021


Commit: 62b50c612f68694662717acb11f3c0789159a978
Author: Hans Goudey
Date:   Tue Nov 23 12:49:45 2021 -0500
Branches: master
https://developer.blender.org/rB62b50c612f68694662717acb11f3c0789159a978

Cleanup: Else after return, other simplifications

`std::stringstream` already returns a `std::string`, and there is no
particular reason to use short here instead of int.

===================================================================

M	source/blender/editors/space_node/node_draw.cc

===================================================================

diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index 1aa6ec4e56c..1d62321cae3 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1664,24 +1664,22 @@ static std::string node_get_execution_time_label(const SpaceNode *snode, const b
   if (exec_time_us == 0) {
     return std::string("-");
   }
-  else if (exec_time_us < 100) {
+  if (exec_time_us < 100) {
     return std::string("< 0.1 ms");
   }
-  else {
-    short precision = 0;
-    /* Show decimal if value is below 1ms */
-    if (exec_time_us < 1000) {
-      precision = 2;
-    }
-    else if (exec_time_us < 10000) {
-      precision = 1;
-    }
 
-    std::stringstream stream;
-    stream << std::fixed << std::setprecision(precision) << (exec_time_us / 1000.0f);
-    return std::string(stream.str() + " ms");
+  int precision = 0;
+  /* Show decimal if value is below 1ms */
+  if (exec_time_us < 1000) {
+    precision = 2;
   }
-  return std::string("");
+  else if (exec_time_us < 10000) {
+    precision = 1;
+  }
+
+  std::stringstream stream;
+  stream << std::fixed << std::setprecision(precision) << (exec_time_us / 1000.0f);
+  return stream.str() + " ms";
 }
 
 struct NodeExtraInfoRow {



More information about the Bf-blender-cvs mailing list