Skip to content

⚡ Bolt: Replace multiple grep() calls with single !grepl()#112

Open
seonghobae wants to merge 1 commit into
masterfrom
bolt-optimise-grep-8016841973574737239
Open

⚡ Bolt: Replace multiple grep() calls with single !grepl()#112
seonghobae wants to merge 1 commit into
masterfrom
bolt-optimise-grep-8016841973574737239

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

💡 What

R/aFIPC.R에서 복수의 부정 grep() 호출을 단일 !grepl()로 교체했습니다.

🎯 Why

base R에서 여러 개의 부정 grep() 출력을 결합하는 것(예: x[-c(grep("A", x), grep("B", x))])은 비효율적일 뿐만 아니라 안전하지 않습니다. 어떤 패턴도 일치하지 않는 경우 x[-integer(0)]으로 평가되어 기대와 달리 character(0)을 반환하여 전체 벡터를 지워버립니다.
추가로 여러 번의 grep 호출은 한 번의 grepl 호출보다 연산 비용이 더 많이 듭니다.

📊 Impact

  • 여러 번의 정규 표현식 검색을 단일 검색으로 줄임으로써 실행 성능을 향상시킵니다.
  • 패턴이 일치하지 않을 때 빈 벡터를 반환하는 잠재적인 버그를 예방합니다.

🔬 Measurement

테스트 스위트를 실행하여 변경 사항이 의도대로 동작하며 버그를 유발하지 않음을 검증했습니다. (Rscript -e "testthat::test_dir('tests/testthat')").


PR created automatically by Jules for task 8016841973574737239 started by @seonghobae

…cal match

- I have replaced multiple negative search index outputs with a single logical match in `R/aFIPC.R`.
- Combining multiple negative search outputs (e.g., `x[-c(find_index("A", x), find_index("B", x))]`) is inefficient and unsafe in base R. If no patterns match, it evaluates to `x[-integer(0)]` which unexpectedly returns `character(0)`, wiping out the entire vector.
- Executing multiple search calls is computationally more expensive than a single logical evaluation.
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant