From b33dc3affcc5caf2ecf0626fd193e43a3168cec1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 6 Jun 2026 07:53:22 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20[Derleme=20hatas=C4=B1=20d?= =?UTF-8?q?=C3=BCzeltmesi=20ve=20gereksiz=20dizi=20kald=C4=B1rma]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Önceki XML düğümü önbellekleme işleminden kalan gereksiz bir statik karakter dizisi (cached_nodes) silindi. Ayrıca, üçlü koşul (ternary) operatöründe farklı dönüş türleri kullanıldığından dolayı oluşan C++ derleme hatası (`const pugi::xml_node` ve `const char[1]`), dönen değerin açıkça `std::string`'e dönüştürülmesiyle çözüldü. Bu işlem, uygulamanın tekrar başarıyla derlenebilmesini sağlar. Co-authored-by: gitmuhammedalbayrak <44205174+gitmuhammedalbayrak@users.noreply.github.com> --- .jules/bolt.md | 4 ++++ src/src-class/Zaman.cpp | 13 ++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index 91f8c13..ed1c28c 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -12,3 +12,7 @@ ## 2026-05-12 - [Remove Duplicate Static Initialization & Unsafe String Operations] **Learning:** The previous optimization attempt introduced a bug where 'cached_nodes' was initialized twice as different types (one array of xml_node pointers, one array of const char*). Moreover, directly casting const char* returned from pugixml without assigning to std::string when used in ternary operations can cause operand type mismatches. **Action:** Removed the redundant array initialization block and cast the char* obtained via `pt.text().get()` from the single cached xml_node array to `std::string` inside the ternary conditional to prevent implicit conversion mismatches. + +## 2026-06-06 - [Avoid Premature Micro-optimizations] +**Learning:** Modern C++ std::string implementations use Small String Optimization (SSO) for strings under ~15-22 characters, allocating them directly on the stack rather than the heap. Attempting to manually replace `std::to_string` with C-style character arrays and ASCII arithmetic for short strings (like "12:59") is a premature micro-optimization that severely harms readability while providing no real-world performance benefit, as heap allocations are already avoided by SSO. +**Action:** Do not sacrifice code readability to avoid `std::to_string` for short formatted strings. Keep utilizing standard idiomatic C++ library features for string generation unless profiling proves it to be an actual bottleneck due to sizes exceeding the SSO limit. diff --git a/src/src-class/Zaman.cpp b/src/src-class/Zaman.cpp index d65d370..f000a07 100644 --- a/src/src-class/Zaman.cpp +++ b/src/src-class/Zaman.cpp @@ -111,16 +111,7 @@ void zaman::vkt_h_v_d() return nodes; }(); - static const char* cached_nodes[400] = {nullptr}; - static bool cached_nodes_init = []() { - for (pugi::xml_node pt = cached_sehir.child("prayertimes"); pt; pt = pt.next_sibling("prayertimes")) { - int day = std::atoi(pt.attribute("dayofyear").value()); - if (day >= 0 && day < 400) cached_nodes[day] = pt.text().get(); - } - return true; - }(); - - zaman::xml_bu_gun = (zaman::h_rakam_gun_senenin >= 0 && zaman::h_rakam_gun_senenin < 400 && cached_nodes[zaman::h_rakam_gun_senenin]) ? cached_nodes[zaman::h_rakam_gun_senenin] : ""; + zaman::xml_bu_gun = (zaman::h_rakam_gun_senenin >= 0 && zaman::h_rakam_gun_senenin < 400 && cached_nodes[zaman::h_rakam_gun_senenin]) ? std::string(cached_nodes[zaman::h_rakam_gun_senenin].text().get()) : ""; zaman::h_aksam = zaman::xml_bu_gun.substr(50, 6); zaman::h_istibak_nucum = zaman::xml_bu_gun.substr(56, 6); @@ -130,7 +121,7 @@ void zaman::vkt_h_v_d() //buradaka kodları yeniliyoruz çünkü bir sonraki gün kılacağız verileri: int next_day = zaman::h_rakam_gun_senenin + 1; - zaman::xml_bu_gun = (next_day >= 0 && next_day < 400 && cached_nodes[next_day]) ? cached_nodes[next_day] : ""; + zaman::xml_bu_gun = (next_day >= 0 && next_day < 400 && cached_nodes[next_day]) ? std::string(cached_nodes[next_day].text().get()) : ""; zaman::h_imsak = zaman::xml_bu_gun.substr(0, 4) ; zaman::h_sabah = zaman::xml_bu_gun.substr(5, 5) ;