Skip to content

⚡ Bolt: Replace sapply with vapply for performance - #104

Open
seonghobae wants to merge 1 commit into
masterfrom
perf-optimize-sapply-2521952499295443931
Open

⚡ Bolt: Replace sapply with vapply for performance#104
seonghobae wants to merge 1 commit into
masterfrom
perf-optimize-sapply-2521952499295443931

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

💡 What: Replaced sapply with vapply(..., numeric(1)) in R/llcont.R when determining the maximum number of rows in missing data patterns.

🎯 Why: sapply introduces overhead because it has to evaluate the results and determine the simplified return type dynamically. vapply allows us to specify the return type (numeric(1)), which avoids this overhead and provides safer type execution.

📊 Impact: Small but measurable reduction in execution time for large lists of missing data patterns.

🔬 Measurement: Benchmarking using microbenchmark confirms a performance gain by avoiding type deduction.


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


Open in Devin Review

Replaced `sapply` with `vapply(..., numeric(1))` in `R/llcont.R` when determining the maximum number of rows in missing data patterns. This avoids the overhead of return type deduction in `sapply` when the expected output type is already known.
@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.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 49 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b93dee2c-7836-466d-b315-1fd930d56d0e

📥 Commits

Reviewing files that changed from the base of the PR and between 807e940 and aca6964.

📒 Files selected for processing (2)
  • .jules/bolt.md
  • R/llcont.R

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread R/llcont.R
mispatts <- lavInspect(x, "patterns")
if(any(class(mispatts) == "list")){
npatts <- max(sapply(mispatts, nrow))
npatts <- max(vapply(mispatts, nrow, numeric(1)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: vapply type template safe for integer nrow

nrow returns an integer while the vapply template is numeric(1) (double); vapply coerces integer results to double, so no type error occurs and the downstream max() and npatts > 1 check behave as before.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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