perf: aplicar checks performance-* (91 fixes)
Cambios aplicados: - Reemplazar std::endl con '\n' (91 casos) * std::endl hace flush del buffer (más lento) * '\n' solo inserta newline (más rápido) * Mejora rendimiento de logging/debug Check excluido: - performance-enum-size: Tamaño de enum no es crítico para rendimiento
This commit is contained in:
@@ -21,7 +21,7 @@ bool Shape::carregar(const std::string& filepath) {
|
||||
// Llegir fitxer
|
||||
std::ifstream file(filepath);
|
||||
if (!file.is_open()) {
|
||||
std::cerr << "[Shape] Error: no es pot obrir " << filepath << std::endl;
|
||||
std::cerr << "[Shape] Error: no es pot obrir " << filepath << '\n';
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ bool Shape::parsejar_fitxer(const std::string& contingut) {
|
||||
try {
|
||||
escala_defecte_ = std::stof(extract_value(line));
|
||||
} catch (...) {
|
||||
std::cerr << "[Shape] Warning: escala invàlida, usant 1.0" << std::endl;
|
||||
std::cerr << "[Shape] Warning: escala invàlida, usant 1.0" << '\n';
|
||||
escala_defecte_ = 1.0F;
|
||||
}
|
||||
} else if (starts_with(line, "center:")) {
|
||||
@@ -66,7 +66,7 @@ bool Shape::parsejar_fitxer(const std::string& contingut) {
|
||||
primitives_.push_back({PrimitiveType::POLYLINE, points});
|
||||
} else {
|
||||
std::cerr << "[Shape] Warning: polyline amb menys de 2 punts ignorada"
|
||||
<< std::endl;
|
||||
<< '\n';
|
||||
}
|
||||
} else if (starts_with(line, "line:")) {
|
||||
auto points = parse_points(extract_value(line));
|
||||
@@ -74,14 +74,14 @@ bool Shape::parsejar_fitxer(const std::string& contingut) {
|
||||
primitives_.push_back({PrimitiveType::LINE, points});
|
||||
} else {
|
||||
std::cerr << "[Shape] Warning: line ha de tenir exactament 2 punts"
|
||||
<< std::endl;
|
||||
<< '\n';
|
||||
}
|
||||
}
|
||||
// Comandes desconegudes ignorades silenciosament
|
||||
}
|
||||
|
||||
if (primitives_.empty()) {
|
||||
std::cerr << "[Shape] Error: cap primitiva carregada" << std::endl;
|
||||
std::cerr << "[Shape] Error: cap primitiva carregada" << '\n';
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ void Shape::parse_center(const std::string& value) {
|
||||
centre_.x = std::stof(trim(val.substr(0, comma)));
|
||||
centre_.y = std::stof(trim(val.substr(comma + 1)));
|
||||
} catch (...) {
|
||||
std::cerr << "[Shape] Warning: centre invàlid, usant (0,0)" << std::endl;
|
||||
std::cerr << "[Shape] Warning: centre invàlid, usant (0,0)" << '\n';
|
||||
centre_ = {.x = 0.0F, .y = 0.0F};
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ std::vector<Punt> Shape::parse_points(const std::string& str) const {
|
||||
points.push_back({x, y});
|
||||
} catch (...) {
|
||||
std::cerr << "[Shape] Warning: punt invàlid ignorat: " << pair
|
||||
<< std::endl;
|
||||
<< '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user