Skip to content

Commit

Permalink
Optimize with raws
Browse files Browse the repository at this point in the history
  • Loading branch information
ms609 committed Apr 3, 2024
1 parent 7a1911e commit 75593a1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions R/length_range.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,10 @@ MaximumLength.numeric <- function(x, compress = NA) {
tokenSums <- colSums(tokens)
active <- c(rep(TRUE, nToken - 1), FALSE)

intersects <- apply(tokens, 2,
function(i) colSums(tokens[i, , drop = FALSE]))
nonIntersect <- !intersects
unions <- vapply(
seq_len(nToken),
function(i) sum(tokens[, i]) + tokenSums - intersects[i, ],
double(nToken)
)
bitTokens <- as.raw(seq_len(nToken))
nonIntersect <- outer(bitTokens, bitTokens, `&`) == 00
unions <- matrix(tokenSums[as.integer(outer(bitTokens, bitTokens, `|`))],
nToken, nToken)
.Merge <- function(a, b) sum(2 ^ (which(tokens[, a] | tokens[, b]) - 1))
loopCount <- 0

Expand Down

0 comments on commit 75593a1

Please sign in to comment.