You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for (intj=0; j<k; ++j) SET_TRUELENGTH(s, 0); // wipe our negative usage and restore 0
839
-
savetl_end(); // then restore R's own usage (if any)
840
-
internal_error(__func__, "levels of target are either not unique or have truelength<0"); // # nocov
841
-
// # nocov end
842
-
}
843
-
SET_TRUELENGTH(s, -k-1);
833
+
hash_set(marks, s, -k-1);
844
834
}
845
835
intnAdd=0;
846
836
for (intk=0; k<nSourceLevels; ++k) {
847
837
constSEXPs=sourceLevelsD[k];
848
-
constinttl=TRUELENGTH(s);
838
+
constinttl=hash_lookup(marks, s, 0);
849
839
if (tl>=0) {
850
840
if (!sourceIsFactor&&s==NA_STRING) continue; // don't create NA factor level when assigning character to factor; test 2117
851
-
if (tl>0) savetl(s);
852
-
SET_TRUELENGTH(s, -nTargetLevels-(++nAdd));
841
+
hash_set(marks, s, -nTargetLevels-(++nAdd));
853
842
} // else, when sourceIsString, it's normal for there to be duplicates here
854
843
}
855
844
constintnSource=length(source);
@@ -858,45 +847,41 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
858
847
constint*sourceD=INTEGER(source);
859
848
for (inti=0; i<nSource; ++i) { // convert source integers to refer to target levels
860
849
constintval=sourceD[i];
861
-
newSourceD[i] =val==NA_INTEGER ? NA_INTEGER : -TRUELENGTH(sourceLevelsD[val-1]); // retains NA factor levels here via TL(NA_STRING); e.g. ordered factor
850
+
newSourceD[i] =val==NA_INTEGER ? NA_INTEGER : -hash_lookup(marks, sourceLevelsD[val-1], 0); // retains NA factor levels here via TL(NA_STRING); e.g. ordered factor
862
851
}
863
852
} else {
864
853
constSEXP*sourceD=STRING_PTR_RO(source);
865
854
for (inti=0; i<nSource; ++i) { // convert source integers to refer to target levels
0 commit comments