get rid of utils::StaticString

In most places this is simply replaced by `std::string_view`.

We also change a few internal/private headers so they accept 
`std::string_view` instead of `utils::CString`.
This commit is contained in:
Mathias Agopian
2022-08-01 14:16:14 -07:00
committed by Mathias Agopian
parent 971df18b3c
commit 5b71274fa5
28 changed files with 155 additions and 340 deletions

View File

@@ -22,11 +22,11 @@
#include <math/vec4.h>
#include <utils/Panic.h>
#include <utils/CString.h>
#include <memory>
#include <vector>
#include <string>
#include <unordered_map>
#include <vector>
using namespace image;
@@ -363,20 +363,19 @@ uint32_t getMipmapCount(const LinearImage& source) {
Filter filterFromString(const char* rawname) {
using namespace utils;
using std::unordered_map;
static const unordered_map<StaticString, Filter, StaticString::Hasher> map = {
{ "BOX", Filter::BOX},
{ "NEAREST", Filter::NEAREST},
{ "HERMITE", Filter::HERMITE},
{ "GAUSSIAN", Filter::GAUSSIAN_SCALARS},
{ "NORMALS", Filter::GAUSSIAN_NORMALS},
{ "MITCHELL", Filter::MITCHELL},
{ "LANCZOS", Filter::LANCZOS},
{ "MINIMUM", Filter::MINIMUM},
static const std::unordered_map<std::string_view, Filter> map = {
{ "BOX", Filter::BOX },
{ "NEAREST", Filter::NEAREST },
{ "HERMITE", Filter::HERMITE },
{ "GAUSSIAN", Filter::GAUSSIAN_SCALARS },
{ "NORMALS", Filter::GAUSSIAN_NORMALS },
{ "MITCHELL", Filter::MITCHELL },
{ "LANCZOS", Filter::LANCZOS },
{ "MINIMUM", Filter::MINIMUM },
};
std::string name = rawname;
for (auto& c: name) { c = toupper((unsigned char)c); }
auto iter = map.find(StaticString::make(name.c_str(), name.size()));
for (auto& c: name) { c = (char)toupper((unsigned char)c); }
auto iter = map.find(name);
return iter == map.end() ? Filter::DEFAULT : iter->second;
}