Skip to content

Commit 6c68fb7

Browse files
committed
simplify
1 parent 91c53c5 commit 6c68fb7

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

R/bmerge.R

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
3434
ans
3535
}
3636

37-
cast_with_atts = function(x, f) {
38-
ans = f(x)
37+
cast_with_atts = function(x, as.f) {
38+
ans = as.f(x)
3939
if (!is.null(attributes(x))) attributes(ans) = attributes(x)
4040
ans
4141
}
@@ -113,8 +113,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
113113
# we've always coerced to int and returned int, for convenience.
114114
if (length(ic_idx)>1L) {
115115
xc_idx = xcols[ic_idx]
116-
for (b in which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")) {
117-
xb = xcols[b]
116+
for (xb in xcols[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
118117
if (isReallyReal(x[[xb]])) {
119118
coerce_x = FALSE
120119
break
@@ -128,8 +127,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
128127
set(callersi, j=ic, value=val) # change the shallow copy of i up in [.data.table to reflect in the result, too.
129128
if (length(ic_idx)>1L) {
130129
xc_idx = xcols[ic_idx]
131-
for (b in which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")) {
132-
xb = xcols[b]
130+
for (xb in xcols[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
133131
if (verbose) catf("Coercing double column %s (which contains no fractions) to type integer to match type of %s.\n", paste0("x.", names(x)[xb]), xname)
134132
set(x, j=xb, value=cast_with_atts(x[[xb]], as.integer))
135133
}
@@ -146,8 +144,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
146144
set(i, j=ic, value=val)
147145
if (length(ic_idx)>1L) {
148146
xc_idx = xcols[ic_idx]
149-
for (b in which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "integer")) {
150-
xb = xcols[b]
147+
for (xb in xcols[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "integer")]) {
151148
if (verbose) catf("Coercing integer column %s to type double for join to match type of %s.\n", paste0("x.", names(x)[xb]), xname)
152149
set(x, j=xb, value=cast_with_atts(x[[xb]], as.double))
153150
}

0 commit comments

Comments
 (0)