MCPcopy Create free account
hub / github.com/ashvardanian/less_slow.cpp / parse_size_string

Function parse_size_string

less_slow.cpp:3114–3120  ·  view source on GitHub ↗

* Takes a string like "64K" and "128M" and returns the corresponding size in * bytes, expanding the multiple prefixes to the actual size, like "65536" and * "134217728", respectively. */

Source from the content-addressed store, hash-verified

3112 * "134217728", respectively.
3113 */
3114std::size_t parse_size_string(std::string const &str) {
3115 std::size_t value = std::stoull(str);
3116 if (str.find("K") != std::string::npos || str.find("k") != std::string::npos) { value *= 1024; }
3117 else if (str.find("M") != std::string::npos || str.find("m") != std::string::npos) { value *= 1024 * 1024; }
3118 else if (str.find("G") != std::string::npos || str.find("g") != std::string::npos) { value *= 1024 * 1024 * 1024; }
3119 return value;
3120}
3121
3122#pragma endregion // Non Uniform Memory Access
3123

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected