File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -298,14 +298,18 @@ attribute_hidden Rcomplex ComplexFromString(SEXP x, int *warn)
298298
299299attribute_hidden SEXP StringFromLogical (int x , int * warn )
300300{
301- static SEXP TrueCh = NULL , FalseCh = NULL ; /* constants, initialized when first used */
301+ static SEXP lglcache = NULL ;
302302 if (x == NA_LOGICAL ) return NA_STRING ;
303- else if (x )
304- return TrueCh != NULL ? TrueCh : (TrueCh = mkChar ("TRUE" ));
305- else return FalseCh != NULL ? FalseCh : (FalseCh = mkChar ("FALSE" ));
303+ if (lglcache == NULL ) {
304+ lglcache = allocVector (STRSXP , 2 );
305+ R_PreserveObject (lglcache );
306+ SET_STRING_ELT (lglcache , 0 , mkChar ("FALSE" ));
307+ SET_STRING_ELT (lglcache , 1 , mkChar ("TRUE" ));
308+ }
309+ return STRING_ELT (lglcache , x ? 1 : 0 );
306310}
307311
308- /* The conversions for small non-negative integers are saved in a chache . */
312+ /* The conversions for small non-negative integers are saved in a cache . */
309313#define SFI_CACHE_SIZE 512
310314static SEXP sficache = NULL ;
311315
You can’t perform that action at this time.
0 commit comments