#update:
DefineExtractor – Update & Refactor
April 2026
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Build System: CMake
The project has been fully migrated to CMake. No more manual VS project setup required.
• New CMakeLists.txt – C++20, automatic thread library linking
• New CMakePresets.json – Debug and Release selectable directly from the VS toolbar dropdown
Output: build/debug/DefineExtractor.exe
Output: build/release/DefineExtractor.exe
• New CMAKE_VS_SETUP.md – step-by-step build guide for Visual Studio 2022/2026
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Performance Optimizations
Analysis revealed 4 stacked issues causing ~96% CPU load and long runtimes
on large codebases (e.g. 449,000 lines):
1. Double file reading (HIGH)
Every file was read twice — once sequentially upfront for line counting,
then again during actual parsing.
Fix: Line count is now accumulated atomically by worker threads during
parsing. No pre-scan pass at all.
2. regex_search on every single line (HIGH)
A complex 4-branch regex pattern was called on every one of 449k+ lines.
Fix: shouldRunDefineRegex() pre-filter — the regex only fires when both
'#' AND the define name are present in the line (~0.1% of lines).
3. anyIfStartRegex inside every active #ifdef block (MEDIUM)
A regex was used to detect nested #if / #ifdef / #ifndef directives.
Fix: Replaced by isAnyIfStart() — plain string character checks, no regex.
4. getIndent() scanned the entire line (MED
#ifdef Used std::accumulate which always iterated to the e#ifof
#ifdefrin
#ifndef Fix: Now breaks at the first non-whitespace character.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Unit Tests (TDD)
Performance helper functions were extracted into DefineExtractor/helpers.h
and are now fully unit-tested (Red → Green → Refactor cycle).
• Framework: Catch2 v2 (single-header, no external install required)
• 18 tests — all passing
• Coverage: getIndent(), isAnyIfStart(), shouldRunDefineRegex()
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Documentation & Repository
• README.md – fully rewritten: CMake build, presets, test guide,
updated project layout (DE/EN)
• CONTRIBUTING.md – bug reports, feature requests, PR workflow,
code style guidelines (DE/EN)
• SECURITY.md – confidential vulnerability reporting process (DE/EN)
• CODE_OF_CONDUCT.md – community standards, Contributor Covenant 2.1 (DE/EN)
• dependabot.yml – fixed invalid package-ecosystem: "" → "github-actions"
• .gitignore – cleaned up: removed leftover game-server entries,
added build/ and Output/
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━