Skip to content

Commit 2f282b2

Browse files
committed
Addressed feedback.
1 parent 4c09a10 commit 2f282b2

File tree

1 file changed

+7
-7
lines changed
  • Core/GameEngine/Source/Common/INI

1 file changed

+7
-7
lines changed

Core/GameEngine/Source/Common/INI/INI.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@
5959
#include "GameLogic/ScriptEngine.h"
6060
#include "GameLogic/Weapon.h"
6161

62-
#if (defined(_MSC_VER) && _MSC_VER < 1300)
63-
#define USE_STD_FROM_CHARS_PARSING 0
64-
#else
62+
#if (defined(__cplusplus) && __cplusplus >= 201606L)
6563
#define USE_STD_FROM_CHARS_PARSING 1
64+
#else
65+
#define USE_STD_FROM_CHARS_PARSING 0
6666
#endif
6767

6868
#if USE_STD_FROM_CHARS_PARSING
6969
#include <charconv>
70+
#include <string_view>
7071
#include <type_traits>
7172
#endif
7273

@@ -1638,12 +1639,11 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList
16381639
#if USE_STD_FROM_CHARS_PARSING
16391640

16401641
template <typename Type>
1641-
Type scanType(const char* token)
1642+
Type scanType(std::string_view token)
16421643
{
1643-
// TheSuperHackers @info std::from_chars cannot parse "-1" as uint32 so the result needs to be a 64 bit type for integers.
1644+
// TheSuperHackers @info std::from_chars cannot parse "-1" as uint32 so the result needs to be int64 for integers.
16441645
std::conditional_t<std::is_integral_v<Type>, Int64, Real> result{};
1645-
// TheSuperHackers @todo Try to optimize this strlen call away by using std::string_view or similar.
1646-
const auto [ptr, ec] = std::from_chars(token, token + strlen(token), result);
1646+
const auto [ptr, ec] = std::from_chars(token.data(), token.data() + token.size(), result);
16471647

16481648
if (ec != std::errc{})
16491649
{

0 commit comments

Comments
 (0)