Bläddra i källkod

UI: Use patterns that avoid std::min/max

New code is cleaner anyway.
jpark37 4 år sedan
förälder
incheckning
c93b040d0d
2 ändrade filer med 10 tillägg och 7 borttagningar
  1. 2 2
      UI/properties-view.cpp
  2. 8 5
      UI/window-basic-preview.cpp

+ 2 - 2
UI/properties-view.cpp

@@ -396,9 +396,9 @@ void OBSPropertiesView::AddFloat(obs_property_t *prop, QFormLayout *layout,
 	const char *suffix = obs_property_float_suffix(prop);
 
 	if (stepVal < 1.0) {
-		int decimals = (int)(log10(1.0 / stepVal) + 0.99);
 		constexpr int sane_limit = 8;
-		decimals = std::min(decimals, sane_limit);
+		const int decimals =
+			std::min<int>(log10(1.0 / stepVal) + 0.99, sane_limit);
 		if (decimals > spin->decimals())
 			spin->setDecimals(decimals);
 	}

+ 8 - 5
UI/window-basic-preview.cpp

@@ -1,7 +1,6 @@
 #include <QGuiApplication>
 #include <QMouseEvent>
 
-#include <algorithm>
 #include <cmath>
 #include <string>
 #include <graphics/vec4.h>
@@ -1049,10 +1048,14 @@ static bool FindItemsInBox(obs_scene_t *scene, obs_sceneitem_t *item,
 	vec3 pos3;
 	vec3 pos3_;
 
-	float x1 = std::min(data->startPos.x, data->pos.x);
-	float x2 = std::max(data->startPos.x, data->pos.x);
-	float y1 = std::min(data->startPos.y, data->pos.y);
-	float y2 = std::max(data->startPos.y, data->pos.y);
+	vec2 pos_min, pos_max;
+	vec2_min(&pos_min, &data->startPos, &data->pos);
+	vec2_max(&pos_max, &data->startPos, &data->pos);
+
+	const float x1 = pos_min.x;
+	const float x2 = pos_max.x;
+	const float y1 = pos_min.y;
+	const float y2 = pos_max.y;
 
 	if (!SceneItemHasVideo(item))
 		return true;