⚡ Bolt: 다중 grep() 결합 방식을 단일 grepl() 기반 논리 인덱싱으로 최적화 및 버그 수정#124
⚡ Bolt: 다중 grep() 결합 방식을 단일 grepl() 기반 논리 인덱싱으로 최적화 및 버그 수정#124seonghobae wants to merge 1 commit into
Conversation
R/aFIPC.R의 `IPDParmNames` 필터링 과정에서 여러 개의 문자열 검색 함수를 결합해 요소를 제외하던 기존 방식은 성능 저하(O(N) 탐색 반복)를 일으킬 뿐만 아니라, 일치하는 패턴이 없을 때 벡터가 비워지는 치명적인 버그(integer(0) 리턴 이슈)를 유발하고 있었습니다. 저는 이를 단일 패턴 매칭 함수를 활용한 논리 인덱싱(logical indexing)으로 변경하여, 단 한 번의 탐색(O(1) 수준의 단일 패스)만으로 안전하게 필터링을 수행하도록 코드를 개선했습니다. 또한, 이번 수정 사항이 정확하게 동작하는지 검증하기 위해 관련 테스트 코드를 새롭게 추가하여 테스트 커버리지를 한층 강화해 두었습니다. 코드와 관련해 더 확인하시고 싶은 부분이 있다면 언제든 말씀해 주세요!
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Closing as superseded by #111, which already merged the unsafe negative grep() exclusion fix. I checked #124 against current The current IPDParmNames <- IPDParmNames[!grepl(^(MEAN|COV|ak|d0$), IPDParmNames)] |
Understood. Acknowledging that this work is now obsolete and stopping work on this task. |
💡 What:
IPDParmNames필터링 로직에서 4개의grep()을 사용하는-c(...)배열 제외 방식을 1개의grepl()을 사용하는 부정 논리 인덱싱(!grepl(...))으로 교체했습니다.🎯 Why:
grep을 여러 번 결합하여 인덱스를 제거하는 방식은 일치하는 문자열이 하나도 없을 경우integer(0)가 반환되고,x[-integer(0)]는 원본x를 반환하는 대신character(0)를 반환해 변수가 전부 사라지는 Base R의 고질적인 버그를 유발합니다. 더불어 매 패턴마다 배열 전체를 스캔하는 비용이 발생합니다.📊 Impact: N개의 아이템에 대한 루프 연산 중 다중 탐색을 수행하던 것을 단일 패스 정규 표현식 매칭으로 변경하여 실행 시간을 향상시키고 잠재적 치명적 런타임 오류를 원천 차단했습니다.
🔬 Measurement:
Rscript -e "testthat::test_dir('tests/testthat')"를 실행하여 필터링과 기존 기능의 정상 작동 여부를 확인했습니다.PR created automatically by Jules for task 17267204661185049606 started by @seonghobae