Skip to content

[Bugzilla#18865] Use any(.) over sum(.) > 0 #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichaelChirico
Copy link
Collaborator

@MichaelChirico MichaelChirico commented Mar 4, 2025

https://bugs.r-project.org/show_bug.cgi?id=18865

Double-checking I didn't do anything sloppy

@MichaelChirico MichaelChirico changed the title use any(.) over sum(.) > 0 [Bugzilla#18865] Use any(.) over sum(.) > 0 Mar 5, 2025
Copy link
Member

@llrs llrs left a comment

Choose a reason for hiding this comment

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

I like those patches!! Thanks!
Just a minor change to make it slightly faster (I thought this was the purpose of these changes, feel free to ignore for a faster review from R core)

@@ -2412,7 +2412,7 @@ classesToAM <- function(classes, includeSubclasses = FALSE,
maybe <- if(!is.null(f <- get0(x, where))) is.function(f) else FALSE
if(maybe)
maybe <- is(f, "genericFunction") ||
(length(grep("UseMethod", deparse(f))) > 0) ||
any(grepl("UseMethod", deparse(f))) ||
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
any(grepl("UseMethod", deparse(f))) ||
any(grepl("UseMethod", deparse(f), fixed = TRUE)) ||

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch! Agree it's an improvement. I don't have an easy workflow for updating patches, so I'll just make a note of it in the issue tracker.

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.

2 participants