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:
@@ -31,7 +31,7 @@ SDLManager::SDLManager()
|
||||
max_zoom_(1.0F) {
|
||||
// Inicialitzar SDL3
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
std::cerr << "Error inicialitzant SDL3: " << SDL_GetError() << std::endl;
|
||||
std::cerr << "Error inicialitzant SDL3: " << SDL_GetError() << '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ SDLManager::SDLManager()
|
||||
);
|
||||
|
||||
if (finestra_ == nullptr) {
|
||||
std::cerr << "Error creant finestra: " << SDL_GetError() << std::endl;
|
||||
std::cerr << "Error creant finestra: " << SDL_GetError() << '\n';
|
||||
SDL_Quit();
|
||||
return;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ SDLManager::SDLManager()
|
||||
renderer_ = SDL_CreateRenderer(finestra_, nullptr);
|
||||
|
||||
if (renderer_ == nullptr) {
|
||||
std::cerr << "Error creant renderer: " << SDL_GetError() << std::endl;
|
||||
std::cerr << "Error creant renderer: " << SDL_GetError() << '\n';
|
||||
SDL_DestroyWindow(finestra_);
|
||||
SDL_Quit();
|
||||
return;
|
||||
@@ -74,7 +74,7 @@ SDLManager::SDLManager()
|
||||
|
||||
std::cout << "SDL3 inicialitzat: " << current_width_ << "x" << current_height_
|
||||
<< " (logic: " << Defaults::Game::WIDTH << "x"
|
||||
<< Defaults::Game::HEIGHT << ")" << std::endl;
|
||||
<< Defaults::Game::HEIGHT << ")" << '\n';
|
||||
}
|
||||
|
||||
// Constructor amb configuració
|
||||
@@ -95,7 +95,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
max_zoom_(1.0F) {
|
||||
// Inicialitzar SDL3
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
std::cerr << "Error inicialitzant SDL3: " << SDL_GetError() << std::endl;
|
||||
std::cerr << "Error inicialitzant SDL3: " << SDL_GetError() << '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
finestra_ = SDL_CreateWindow(window_title.c_str(), current_width_, current_height_, flags);
|
||||
|
||||
if (finestra_ == nullptr) {
|
||||
std::cerr << "Error creant finestra: " << SDL_GetError() << std::endl;
|
||||
std::cerr << "Error creant finestra: " << SDL_GetError() << '\n';
|
||||
SDL_Quit();
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
renderer_ = SDL_CreateRenderer(finestra_, nullptr);
|
||||
|
||||
if (renderer_ == nullptr) {
|
||||
std::cerr << "Error creant renderer: " << SDL_GetError() << std::endl;
|
||||
std::cerr << "Error creant renderer: " << SDL_GetError() << '\n';
|
||||
SDL_DestroyWindow(finestra_);
|
||||
SDL_Quit();
|
||||
return;
|
||||
@@ -153,7 +153,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
if (is_fullscreen_) {
|
||||
std::cout << " [FULLSCREEN]";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
SDLManager::~SDLManager() {
|
||||
@@ -168,7 +168,7 @@ SDLManager::~SDLManager() {
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
std::cout << "SDL3 netejat correctament" << std::endl;
|
||||
std::cout << "SDL3 netejat correctament" << '\n';
|
||||
}
|
||||
|
||||
void SDLManager::calculateMaxWindowSize() {
|
||||
@@ -181,13 +181,13 @@ void SDLManager::calculateMaxWindowSize() {
|
||||
max_height_ = mode->h - 100;
|
||||
std::cout << "Display detectat: " << mode->w << "x" << mode->h
|
||||
<< " (max finestra: " << max_width_ << "x" << max_height_ << ")"
|
||||
<< std::endl;
|
||||
<< '\n';
|
||||
} else {
|
||||
// Fallback conservador
|
||||
max_width_ = 1920;
|
||||
max_height_ = 1080;
|
||||
std::cerr << "No s'ha pogut detectar el display, usant fallback: "
|
||||
<< max_width_ << "x" << max_height_ << std::endl;
|
||||
<< max_width_ << "x" << max_height_ << '\n';
|
||||
}
|
||||
|
||||
// Calculate max zoom immediately after determining max size
|
||||
@@ -209,7 +209,7 @@ void SDLManager::calculateMaxZoom() {
|
||||
max_zoom_ = std::max(max_zoom_, Defaults::Window::MIN_ZOOM);
|
||||
|
||||
std::cout << "Max zoom: " << max_zoom_ << "x (display: "
|
||||
<< max_width_ << "x" << max_height_ << ")" << std::endl;
|
||||
<< max_width_ << "x" << max_height_ << ")" << '\n';
|
||||
}
|
||||
|
||||
void SDLManager::applyZoom(float new_zoom) {
|
||||
@@ -249,7 +249,7 @@ void SDLManager::applyZoom(float new_zoom) {
|
||||
Options::window.zoom_factor = zoom_factor_;
|
||||
|
||||
std::cout << "Zoom: " << zoom_factor_ << "x ("
|
||||
<< new_width << "x" << new_height << ")" << std::endl;
|
||||
<< new_width << "x" << new_height << ")" << '\n';
|
||||
}
|
||||
|
||||
void SDLManager::updateLogicalPresentation() {
|
||||
@@ -279,7 +279,7 @@ void SDLManager::updateViewport() {
|
||||
|
||||
std::cout << "Viewport: " << scaled_width << "x" << scaled_height
|
||||
<< " @ (" << offset_x << "," << offset_y << ") [scale=" << scale << "]"
|
||||
<< std::endl;
|
||||
<< '\n';
|
||||
}
|
||||
|
||||
void SDLManager::updateRenderingContext() const {
|
||||
@@ -295,7 +295,7 @@ void SDLManager::increaseWindowSize() {
|
||||
float new_zoom = zoom_factor_ + Defaults::Window::ZOOM_INCREMENT;
|
||||
applyZoom(new_zoom);
|
||||
|
||||
std::cout << "F2: Zoom aumentat a " << zoom_factor_ << "x" << std::endl;
|
||||
std::cout << "F2: Zoom aumentat a " << zoom_factor_ << "x" << '\n';
|
||||
}
|
||||
|
||||
void SDLManager::decreaseWindowSize() {
|
||||
@@ -306,7 +306,7 @@ void SDLManager::decreaseWindowSize() {
|
||||
float new_zoom = zoom_factor_ - Defaults::Window::ZOOM_INCREMENT;
|
||||
applyZoom(new_zoom);
|
||||
|
||||
std::cout << "F1: Zoom reduït a " << zoom_factor_ << "x" << std::endl;
|
||||
std::cout << "F1: Zoom reduït a " << zoom_factor_ << "x" << '\n';
|
||||
}
|
||||
|
||||
void SDLManager::applyWindowSize(int new_width, int new_height) {
|
||||
@@ -352,7 +352,7 @@ void SDLManager::toggleFullscreen() {
|
||||
SDL_SetWindowFullscreen(finestra_, true);
|
||||
|
||||
std::cout << "F3: Fullscreen activat (guardada: "
|
||||
<< windowed_width_ << "x" << windowed_height_ << ")" << std::endl;
|
||||
<< windowed_width_ << "x" << windowed_height_ << ")" << '\n';
|
||||
} else {
|
||||
// EXITING FULLSCREEN
|
||||
is_fullscreen_ = false;
|
||||
@@ -362,7 +362,7 @@ void SDLManager::toggleFullscreen() {
|
||||
applyWindowSize(windowed_width_, windowed_height_);
|
||||
|
||||
std::cout << "F3: Fullscreen desactivat (restaurada: "
|
||||
<< windowed_width_ << "x" << windowed_height_ << ")" << std::endl;
|
||||
<< windowed_width_ << "x" << windowed_height_ << ")" << '\n';
|
||||
}
|
||||
|
||||
Options::window.fullscreen = is_fullscreen_;
|
||||
@@ -392,7 +392,7 @@ bool SDLManager::handleWindowEvent(const SDL_Event& event) {
|
||||
|
||||
std::cout << "Finestra redimensionada: " << current_width_
|
||||
<< "x" << current_height_ << " (zoom ≈" << zoom_factor_ << "x)"
|
||||
<< std::endl;
|
||||
<< '\n';
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user