diff --git a/.jules/bolt.md b/.jules/bolt.md index 165882d..ff82bb8 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -46,3 +46,7 @@ ## 2025-01-24 - 단일 readAttributes 호출로 파일 속성 조회 최적화 (순회 루프) **학습:** 디렉토리 순회 루프 내에서 isDirectory 및 isSymbolicLink 두 번의 stat을 각각 호출하면 파일 시스템 I/O 오버헤드가 배가됩니다. 메모리 내 제외 규칙 확인 후 한 번의 readAttributes로 속성을 한 번에 가져오는 것이 훨씬 빠릅니다. **조치:** Files.isDirectory 및 Files.isSymbolicLink를 단일 Files.readAttributes 호출로 교체하여 O(N) I/O 통신을 최적화했습니다. + +## 2026-08-09 - 반복 호출되는 함수 내 정적 리스트 최적화 +**Learning:** 디렉토리를 탐색할 때마다 호출되는 함수(process_ignore_file) 내부에서 listOf()로 고정된 리스트를 할당하면 불필요한 메모리 할당과 GC 부하가 발생합니다. +**Action:** 정적인 컬렉션은 private object로 추출하고 @JvmField 등을 활용하여 단 한 번만 초기화되도록 최적화해야 합니다. diff --git a/src/main/kotlin/html4tree/main.kt b/src/main/kotlin/html4tree/main.kt index e8acd01..4daada9 100644 --- a/src/main/kotlin/html4tree/main.kt +++ b/src/main/kotlin/html4tree/main.kt @@ -323,9 +323,9 @@ fun process_ignore_file(curr_dir: File, dirFilesNames: Array? = null): S if ("index.html" !in files_to_exclude) files_to_exclude.add("index.html") + // ⚡ Bolt Performance Optimization: Extract static list to prevent redundant allocations per directory // 보안 향상: 민감한 시스템, 설정, 시크릿 파일을 디렉토리 목록에서 기본적으로 제외하여 정보 노출(Information Exposure) 방지 - val defaultSensitiveFiles = listOf(".git", ".env", ".ssh", ".htpasswd", ".htaccess", "id_rsa", "id_ed25519", "secrets.yml", ".html4ignore", ".DS_Store", ".aws", ".kube", ".npmrc", ".gnupg", "config.json", "credentials.json") - files_to_exclude.addAll(defaultSensitiveFiles) + files_to_exclude.addAll(Constants.defaultSensitiveFiles) // 보안 향상: dot-like prefixes are treated as hidden to prevent visually-confusable sensitive entries from reaching generated indexes. (dirFilesNames ?: curr_dir.list())?.forEach { @@ -458,3 +458,8 @@ fun process_dir(curr_dir: File, excludeSet: Set? = null, dirFiles: Array fun help() { println("ERROR: help has not been written yet!") } + +private object Constants { + @JvmField + val defaultSensitiveFiles = listOf(".git", ".env", ".ssh", ".htpasswd", ".htaccess", "id_rsa", "id_ed25519", "secrets.yml", ".html4ignore", ".DS_Store", ".aws", ".kube", ".npmrc", ".gnupg", "config.json", "credentials.json") +}