refactor: eliminar ShapeLoader::resolvePath i BASE_PATH (codi mort)
Cap caller invocava resolvePath fora de la seua pròpia definició. A més, BASE_PATH apuntava a "data/shapes/" mentre que load() ja construeix el path amb el prefix "shapes/" directament — el helper mai s'hauria activat encara que es cridara. Hallazgo #18 de CODE_REVIEW.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -67,19 +67,4 @@ void ShapeLoader::clearCache() {
|
|||||||
|
|
||||||
auto ShapeLoader::getCacheSize() -> size_t { return cache.size(); }
|
auto ShapeLoader::getCacheSize() -> size_t { return cache.size(); }
|
||||||
|
|
||||||
auto ShapeLoader::resolvePath(const std::string& filename) -> std::string {
|
|
||||||
// Si es un path absolut (comença con '/'), usar-lo directament
|
|
||||||
if (!filename.empty() && filename[0] == '/') {
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si ya conté el prefix base_path, usar-lo directament
|
|
||||||
if (filename.starts_with(BASE_PATH)) {
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Altrament, añadir base_path (ara suporta subdirectoris)
|
|
||||||
return std::string(BASE_PATH) + filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Graphics
|
} // namespace Graphics
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ class ShapeLoader {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unordered_map<std::string, std::shared_ptr<Shape>> cache;
|
static std::unordered_map<std::string, std::shared_ptr<Shape>> cache;
|
||||||
static constexpr const char* BASE_PATH = "data/shapes/";
|
|
||||||
|
|
||||||
// Helpers privats
|
|
||||||
static auto resolvePath(const std::string& filename) -> std::string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Graphics
|
} // namespace Graphics
|
||||||
|
|||||||
Reference in New Issue
Block a user