| 832 | // Parse float array directly from span into vector (zero allocations) |
| 833 | template<typename T> |
| 834 | bool parse_float_array(const fl::span<const char>& span, fl::vector<T>& out_vec) { |
| 835 | const char* p = span.data(); |
| 836 | const char* end = p + span.size(); |
| 837 | |
| 838 | while (p < end) { |
| 839 | // Skip whitespace |
| 840 | while (p < end && (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r')) p++; |
| 841 | if (p >= end) break; |
| 842 | |
| 843 | // Parse number |
| 844 | const char* num_start = p; |
| 845 | bool is_float = false; |
| 846 | |
| 847 | if (*p == '-') p++; |
| 848 | while (p < end && *p >= '0' && *p <= '9') p++; |
| 849 | |
| 850 | if (p < end && *p == '.') { |
| 851 | is_float = true; |
| 852 | p++; |
| 853 | while (p < end && *p >= '0' && *p <= '9') p++; |
| 854 | } |
| 855 | |
| 856 | if (p < end && (*p == 'e' || *p == 'E')) { |
| 857 | is_float = true; |
| 858 | p++; |
| 859 | if (p < end && (*p == '+' || *p == '-')) p++; |
| 860 | while (p < end && *p >= '0' && *p <= '9') p++; |
| 861 | } |
| 862 | |
| 863 | T val; |
| 864 | if (is_float) { |
| 865 | #if FL_PLATFORM_HAS_LARGE_MEMORY |
| 866 | // Bit-twiddling parse -> IEEE 754 bit pattern -> bit-cast to float. |
| 867 | // The `static_cast<T>` from `float` is the caller's responsibility |
| 868 | // (e.g. T=float costs nothing; T=int pulls one __aeabi_f2iz at the |
| 869 | // call site, which we accept per the "user opts in" mandate). |
| 870 | const u32 bits = fl::ieee754_parse_decimal(num_start, p - num_start); |
| 871 | val = static_cast<T>(fl::bit_cast<float>(bits)); |
| 872 | #else |
| 873 | // Low-memory gate per FastLED #3082: float JSON literals in |
| 874 | // packed-array parse path saturate to zero. The integer-only |
| 875 | // RPC contract on LPC8xx / AVR never emits floats here. |
| 876 | val = static_cast<T>(0); |
| 877 | #endif |
| 878 | } else { |
| 879 | val = static_cast<T>(fl::parseInt(num_start, p - num_start)); |
| 880 | } |
| 881 | out_vec.push_back(val); |
| 882 | |
| 883 | // Skip whitespace |
| 884 | while (p < end && (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r')) p++; |
| 885 | |
| 886 | // Skip comma |
| 887 | if (p < end && *p == ',') p++; |
| 888 | } |
| 889 | |
| 890 | return true; |
| 891 | } |
nothing calls this directly
no test coverage detected