Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Slightly more idiomatic C code

  • Loading branch information...
commit 0a7899d34cb4e4314aa02c29cd7885df7a7fa38b 1 parent 8453287
@hadley authored
Showing with 2 additions and 5 deletions.
  1. +2 −5 src/split-numeric.c
View
7 src/split-numeric.c
@@ -5,12 +5,9 @@ SEXP split_indices(SEXP group, SEXP n) {
SEXP vec;
int i, j, k, nobs, nlevs;
- PROTECT(group = AS_INTEGER(group));
-
nlevs = INTEGER(n)[0];
nobs = LENGTH(group);
-
// Count number of cases in each group
int counts[nlevs];
for (i = 0; i < nlevs; i++)
@@ -34,8 +31,8 @@ SEXP split_indices(SEXP group, SEXP n) {
j = INTEGER(group)[i] - 1;
k = counts[j];
INTEGER(VECTOR_ELT(vec, j))[k] = i + 1;
- counts[j] += 1;
+ counts[j]++;
}
- UNPROTECT(2);
+ UNPROTECT(1);
return vec;
}
Please sign in to comment.
Something went wrong with that request. Please try again.