From 00f807185f062197eb235fae04694561cef8c4bf Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 4 Sep 2026 03:42:50 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=A1=20Bolt:=20[=EC=84=B1=EB=8A=A5=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0]=20=ED=8C=8C=EC=9D=BC=EB=AA=85=20=EC=A7=80?= =?UTF-8?q?=EC=97=B0=20=ED=8F=89=EA=B0=80=EB=A5=BC=20=ED=86=B5=ED=95=9C=20?= =?UTF-8?q?GC=20=ED=95=A0=EB=8B=B9=20=EC=B5=9C=EC=A0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jules/bolt.md | 4 ++++ src/main/kotlin/html4tree/main.kt | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index ee124e69..75262117 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -62,3 +62,7 @@ ## 2026-08-11 - Array의 toMutableList 할당 오버헤드 최적화 **학습:** 배열을 정렬하기 위해 `.toMutableList()`를 호출하면 새로운 `ArrayList` 객체와 내부 배열 객체가 할당되어 대규모 디렉토리를 순회할 때 가비지 컬렉션(GC) 부하를 유발합니다. 배열 복제가 필요한 경우 `.clone()`을 사용하면 하나의 배열 객체만 새로 할당되므로 더 효율적입니다. **조치:** 디렉토리 파일 배열을 정렬하기 전에 복사할 때 `.toMutableList()` 대신 `.clone()`을 사용하여 불필요한 중간 컬렉션 할당을 제거하고 성능을 향상시켰습니다. + +## 2024-06-03 - 지연 평가를 통한 GC 압력 감소 +**Learning:** 파일 목록 루프에서 `.toLowerCase()` 같은 비용이 큰 문자열 할당 연산을 미리 수행하면, 조건문에서 조기 종료될 항목들에 대해서도 불필요한 메모리 할당과 GC 압력이 발생합니다. +**Action:** 조건문 내에서 값이 변하지 않고 검사가 빠르고 간단한 속성(예: `isHiddenFile()`, `endsWith()`)을 먼저 평가한 후, 이를 통과한 항목에 한해서만 고비용 연산(예: `toLowerCase()`)을 수행하도록 평가 순서를 재배치합니다. diff --git a/src/main/kotlin/html4tree/main.kt b/src/main/kotlin/html4tree/main.kt index 0972fa2c..4c07ff22 100644 --- a/src/main/kotlin/html4tree/main.kt +++ b/src/main/kotlin/html4tree/main.kt @@ -351,16 +351,20 @@ fun process_ignore_file(curr_dir: File, dirFilesNames: Array? = null): S // 보안 향상: dot-like prefixes and case variants of known sensitive names are excluded. (dirFilesNames ?: curr_dir.list())?.forEach { - val normalizedName = it.toLowerCase(java.util.Locale.ROOT) - if ( - it.isHiddenFile() || - normalizedName in Constants.defaultSensitiveFileNamesLowercase || - normalizedName.endsWith("~") || - Constants.defaultSensitiveExtensions.any { extension -> - normalizedName.endsWith(extension) - } - ) { + if (it.isHiddenFile() || it.endsWith("~")) { files_to_exclude.add(it) + } else { + // ⚡ Bolt Performance Optimization: Defer expensive string allocation + // (toLowerCase) until after evaluating cheap, short-circuiting properties. + val normalizedName = it.toLowerCase(java.util.Locale.ROOT) + if ( + normalizedName in Constants.defaultSensitiveFileNamesLowercase || + Constants.defaultSensitiveExtensions.any { extension -> + normalizedName.endsWith(extension) + } + ) { + files_to_exclude.add(it) + } } } From c9168895cba0d9dccde33efeb978a165be90ba1c Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Fri, 4 Sep 2026 13:22:39 +0900 Subject: [PATCH 2/2] docs(perf): keep lowercasing optimization evidence-bounded --- .jules/bolt.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index 75262117..ee124e69 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -62,7 +62,3 @@ ## 2026-08-11 - Array의 toMutableList 할당 오버헤드 최적화 **학습:** 배열을 정렬하기 위해 `.toMutableList()`를 호출하면 새로운 `ArrayList` 객체와 내부 배열 객체가 할당되어 대규모 디렉토리를 순회할 때 가비지 컬렉션(GC) 부하를 유발합니다. 배열 복제가 필요한 경우 `.clone()`을 사용하면 하나의 배열 객체만 새로 할당되므로 더 효율적입니다. **조치:** 디렉토리 파일 배열을 정렬하기 전에 복사할 때 `.toMutableList()` 대신 `.clone()`을 사용하여 불필요한 중간 컬렉션 할당을 제거하고 성능을 향상시켰습니다. - -## 2024-06-03 - 지연 평가를 통한 GC 압력 감소 -**Learning:** 파일 목록 루프에서 `.toLowerCase()` 같은 비용이 큰 문자열 할당 연산을 미리 수행하면, 조건문에서 조기 종료될 항목들에 대해서도 불필요한 메모리 할당과 GC 압력이 발생합니다. -**Action:** 조건문 내에서 값이 변하지 않고 검사가 빠르고 간단한 속성(예: `isHiddenFile()`, `endsWith()`)을 먼저 평가한 후, 이를 통과한 항목에 한해서만 고비용 연산(예: `toLowerCase()`)을 수행하도록 평가 순서를 재배치합니다.