Skip to content

Commit 04b6864

Browse files
committed
Use global string constants for Infinity and NaN
1 parent c8e7f2d commit 04b6864

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/scratch/value_functions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,16 @@ extern "C"
374374
} else if (std::isinf(v)) {
375375
if (v > 0) {
376376
StringPtr *ret = string_pool_new();
377-
string_assign_cstring(ret, "Infinity");
377+
string_assign(ret, &INFINITY_STR);
378378
return ret;
379379
} else {
380380
StringPtr *ret = string_pool_new();
381-
string_assign_cstring(ret, "-Infinity");
381+
string_assign(ret, &NEGATIVE_INFINITY_STR);
382382
return ret;
383383
}
384384
} else if (std::isnan(v)) {
385385
StringPtr *ret = string_pool_new();
386-
string_assign_cstring(ret, "NaN");
386+
string_assign(ret, &NAN_STR);
387387
return ret;
388388
}
389389

src/scratch/value_functions_p.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ namespace libscratchcpp
2323

2424
static const StringPtr TRUE_STR("true");
2525
static const StringPtr FALSE_STR("false");
26+
static const StringPtr INFINITY_STR("Infinity");
27+
static const StringPtr NEGATIVE_INFINITY_STR("-Infinity");
28+
static const StringPtr NAN_STR("NaN");
2629

2730
template<typename T>
2831
inline unsigned int value_intDigitCount(T v)

0 commit comments

Comments
 (0)