Cut core/model, reclaim, json, util comment bloat ~26% (comments only, zero code change)
This commit is contained in:
@@ -5,19 +5,13 @@
|
||||
|
||||
// bank_book implementation — the registry RULES half: construction, pool
|
||||
// privileges, bank lifecycle, active bank, sample movement/removal, slot order,
|
||||
// and the reference queries. The JSON round-trip half (serialize / deserialize —
|
||||
// Q-W1's golden-literal-pinned byte format) lives in bank_book_json.cpp, compiled
|
||||
// into the same bank_book target (the slot_map extraction shape: same header, a
|
||||
// second TU). The one symbol both halves share is the private static
|
||||
// BankBook::nameKey display-name folding rule (declared in bank_book.h).
|
||||
// and the reference queries. The JSON round-trip half lives in bank_book_json.cpp,
|
||||
// compiled into the same target. The one symbol both halves share is the private
|
||||
// static BankBook::nameKey display-name folding rule (declared in bank_book.h).
|
||||
|
||||
namespace reasampler {
|
||||
|
||||
// SlotMap lives in core/model/slot_map.cpp (extracted Q-W1, T4-05).
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// BankBook — construction + bank lookup
|
||||
// ---------------------------------------------------------------------------
|
||||
// -- construction + bank lookup ----------------------------------------------
|
||||
|
||||
BankBook::BankBook() {
|
||||
Bank pool;
|
||||
@@ -59,9 +53,7 @@ const Bank& BankBook::pool() const {
|
||||
return *bank(kPoolBankId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Ordinal normalization
|
||||
// ---------------------------------------------------------------------------
|
||||
// -- Ordinal normalization ----------------------------------------------------
|
||||
|
||||
void BankBook::normalizeOrdinals() {
|
||||
// Stable-sort by ordinal with the pool pinned first, then rewrite ordinals to a
|
||||
@@ -75,16 +67,13 @@ void BankBook::normalizeOrdinals() {
|
||||
banks_[i].ordinal = static_cast<int>(i);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Display-name uniqueness (trimmed + case-insensitive, ASCII)
|
||||
// ---------------------------------------------------------------------------
|
||||
// -- Display-name uniqueness (trimmed + case-insensitive, ASCII) --------------
|
||||
|
||||
// Folds a display name to its uniqueness key: strip leading/trailing ASCII
|
||||
// whitespace, lower-case ASCII letters. So "Drums", "drums", and " Drums " share one
|
||||
// key and cannot coexist. ASCII-only by design — the pure core carries no locale
|
||||
// facility and must not grow one; bank names are short user labels, not full Unicode
|
||||
// case-folding candidates. Private static member (Q-W5): the one folding rule shared
|
||||
// with bank_book_json.cpp's parse-time duplicate-display-name coalesce.
|
||||
// whitespace, lower-case ASCII letters — so "Drums"/"drums"/" Drums " share one
|
||||
// key. ASCII-only by design — the pure core carries no locale facility; bank names
|
||||
// are short user labels, not Unicode case-folding candidates. Private static: the
|
||||
// one folding rule shared with bank_book_json.cpp's parse-time coalesce.
|
||||
std::string BankBook::nameKey(const std::string& s) {
|
||||
std::size_t b = 0, e = s.size();
|
||||
auto isWs = [](char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\r'; };
|
||||
@@ -109,9 +98,7 @@ bool BankBook::displayNameTaken(const std::string& name, const std::string& exce
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Bank lifecycle
|
||||
// ---------------------------------------------------------------------------
|
||||
// -- Bank lifecycle ------------------------------------------------------------
|
||||
|
||||
bool BankBook::createBank(const std::string& id, const std::string& displayName) {
|
||||
if (id.empty()) return false; // ids key the registry
|
||||
@@ -208,9 +195,7 @@ bool BankBook::evacuate(const std::string& id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Active bank
|
||||
// ---------------------------------------------------------------------------
|
||||
// -- Active bank ----------------------------------------------------------------
|
||||
|
||||
bool BankBook::setActiveBank(const std::string& id) {
|
||||
if (bank(id) == nullptr) return false; // unknown id never corrupts state
|
||||
@@ -227,9 +212,7 @@ const BankModel& BankBook::activeIndex() const {
|
||||
return bank(activeBankId_)->index;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sample movement (index-only)
|
||||
// ---------------------------------------------------------------------------
|
||||
// -- Sample movement (index-only) -----------------------------------------------
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -276,9 +259,7 @@ TransferResult BankBook::copySample(const std::string& sampleId,
|
||||
return applyDestAdd(to->index, copy, TransferResult::Copied);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sample removal (index-only) + the last-reference query
|
||||
// ---------------------------------------------------------------------------
|
||||
// -- Sample removal (index-only) + the last-reference query ---------------------
|
||||
|
||||
RemoveResult BankBook::removeSample(const std::string& sampleId,
|
||||
const std::string& fromBankId,
|
||||
@@ -310,9 +291,7 @@ bool BankBook::updateSampleInPlace(const std::string& sampleId, const Sample& up
|
||||
return false; // no bank holds the id
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sample display order (L7) — SlotMap driven, index membership untouched
|
||||
// ---------------------------------------------------------------------------
|
||||
// -- Sample display order — SlotMap driven, index membership untouched -----------
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -323,9 +302,9 @@ std::vector<std::string> indexIds(const BankModel& idx) {
|
||||
return ids;
|
||||
}
|
||||
|
||||
// Squares one bank's SlotMap with its index membership. A map with NO overlap with the
|
||||
// index (the pre-L7 migration case, or a freshly-constructed bank) is seeded dense from
|
||||
// insertion order; an existing map is reconciled (drop stale markers, append unmapped).
|
||||
// Squares one bank's SlotMap with its index membership. A map with NO overlap with
|
||||
// the index (a bank with no persisted slot data, or freshly constructed) is seeded
|
||||
// dense from insertion order; an existing map is reconciled (drop stale, append unmapped).
|
||||
void reconcileBankSlots(Bank& b) {
|
||||
const std::vector<std::string> live = indexIds(b.index);
|
||||
if (b.slots.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user