Skip to content
Open
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-10-24 - 핫 루프 내 문자열 할당 지연 최적화
**학습:** 디렉토리 순회와 같은 핫 루프 내에서 파일 이름을 검사할 때, `.toLowerCase()`와 같은 문자열 할당 함수를 조기에 호출하면 가비지 컬렉션(GC) 압력을 증가시키고 성능을 저하시킵니다. `isHiddenFile()`이나 `.endsWith("~")`과 같은 저렴한 연산을 먼저 수행하면 불필요한 할당을 피할 수 있습니다.
**조치:** 무거운 작업(문자열 할당)을 루프 초기에 수행하는 대신, 저렴하고 조기 종료가 가능한 조건(`isHiddenFile()` 등)을 먼저 검사한 후, 그 조건에 맞지 않을 때만 무거운 작업을 수행하도록 `if-else` 블록 또는 지연 평가를 사용합니다.
22 changes: 13 additions & 9 deletions src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,20 @@ 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)
}
) {
// ⚡ Bolt Performance Optimization: Defer expensive string allocation (toLowerCase)
// after evaluating cheap, short-circuiting properties to reduce GC pressure.
if (it.isHiddenFile() || it.endsWith("~")) {
files_to_exclude.add(it)
} else {
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)
}
}
}

Expand Down
Loading