Browse Source

Math: use String::contains() instead of std::find().

An old TODO, yay!
pull/556/head
Vladimír Vondruš 4 years ago
parent
commit
9f65db2e2b
  1. 10
      src/Magnum/Math/Angle.cpp
  2. 3
      src/Magnum/Math/Half.cpp

10
src/Magnum/Math/Angle.cpp

@ -26,7 +26,7 @@
#include "Angle.h"
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
#include <algorithm> /** @todo get rid of this once StringView::find() exists */
#include <cstdlib>
#include <Corrade/Containers/StringView.h>
#include <Corrade/Utility/TweakableParser.h>
@ -38,7 +38,7 @@ std::pair<TweakableState, Magnum::Math::Deg<Magnum::Float>> TweakableParser<Magn
char* end;
const Magnum::Float result = std::strtof(value.data(), &end);
if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) {
if(end == value.begin() || !value.contains('.')) {
Warning{} << "Utility::TweakableParser:" << value << "is not an angle literal";
return {TweakableState::Recompile, {}};
}
@ -62,7 +62,7 @@ std::pair<TweakableState, Magnum::Math::Deg<Magnum::Double>> TweakableParser<Mag
char* end;
const Magnum::Double result = std::strtod(value.data(), &end);
if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) {
if(end == value.begin() || !value.contains('.')) {
Warning{} << "Utility::TweakableParser:" << value << "is not an angle literal";
return {TweakableState::Recompile, {}};
}
@ -86,7 +86,7 @@ std::pair<TweakableState, Magnum::Math::Rad<Magnum::Float>> TweakableParser<Magn
char* end;
const Magnum::Float result = std::strtof(value.data(), &end);
if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) {
if(end == value.begin() || !value.contains('.')) {
Warning{} << "Utility::TweakableParser:" << value << "is not an angle literal";
return {TweakableState::Recompile, {}};
}
@ -110,7 +110,7 @@ std::pair<TweakableState, Magnum::Math::Rad<Magnum::Double>> TweakableParser<Mag
char* end;
const Magnum::Double result = std::strtod(value.data(), &end);
if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) {
if(end == value.begin() || !value.contains('.')) {
Warning{} << "Utility::TweakableParser:" << value << "is not an angle literal";
return {TweakableState::Recompile, {}};
}

3
src/Magnum/Math/Half.cpp

@ -30,7 +30,6 @@
#include <Corrade/Utility/DebugStl.h>
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
#include <algorithm> /** @todo get rid of this once StringView::find() exists */
#include <Corrade/Containers/StringView.h>
#include <Corrade/Utility/TweakableParser.h>
#endif
@ -56,7 +55,7 @@ std::pair<TweakableState, Magnum::Math::Half> TweakableParser<Magnum::Math::Half
char* end;
const Magnum::Float result = std::strtof(value.data(), &end);
if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) {
if(end == value.begin() || !value.contains('.')) {
Warning{} << "Utility::TweakableParser:" << value << "is not a half literal";
return {TweakableState::Recompile, {}};
}

Loading…
Cancel
Save