Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@
## 2026-08-11 - Array의 toMutableList 할당 오버헤드 최적화
**학습:** 배열을 정렬하기 위해 `.toMutableList()`를 호출하면 새로운 `ArrayList` 객체와 내부 배열 객체가 할당되어 대규모 디렉토리를 순회할 때 가비지 컬렉션(GC) 부하를 유발합니다. 배열 복제가 필요한 경우 `.clone()`을 사용하면 하나의 배열 객체만 새로 할당되므로 더 효율적입니다.
**조치:** 디렉토리 파일 배열을 정렬하기 전에 복사할 때 `.toMutableList()` 대신 `.clone()`을 사용하여 불필요한 중간 컬렉션 할당을 제거하고 성능을 향상시켰습니다.

## 2024-05-18 - 문자열 할당의 지연 평가를 통한 GC 부하 감소
**Learning:** 핫 패스 루프에서 `toLowerCase()`와 같은 비싼 문자열 할당 연산을 가장 먼저 수행하면, 이후의 간단한 조건(`isHiddenFile()`, `endsWith()`)으로 인해 버려지는 객체들로 인해 불필요한 가비지 컬렉션(GC) 압력이 발생합니다.
**Action:** 빠른 반환이 가능한 저렴한 조건들을 먼저 평가하여, 실질적으로 변환이 필요한 경우에만 비싼 문자열 할당이 일어나도록 조건문을 재배치해야 합니다.
13 changes: 8 additions & 5 deletions src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,16 @@ fun process_ignore_file(curr_dir: File, dirFilesNames: Array<String>? = 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)
it.endsWith("~") ||
// ⚡ Bolt Performance Optimization: Defer expensive string allocation (toLowerCase)
// Evaluated only if cheap short-circuiting properties fail.
it.toLowerCase(java.util.Locale.ROOT).let { normalizedName ->
normalizedName in Constants.defaultSensitiveFileNamesLowercase ||
Constants.defaultSensitiveExtensions.any { extension ->
normalizedName.endsWith(extension)
}
}
) {
files_to_exclude.add(it)
Expand Down
Loading