From a3c56ac2c047811e36965b2eb4195998e03bc8ea Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sat, 6 Jul 2024 21:16:44 -0500 Subject: [PATCH 1/4] remove Rf_findVarInFrame3 --- r/src/arrow_cpp11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index ab605866281..eacddd08773 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -394,7 +394,7 @@ SEXP to_r6(const std::shared_ptr& ptr, const char* r6_class_name) { cpp11::external_pointer> xp(new std::shared_ptr(ptr)); SEXP r6_class = Rf_install(r6_class_name); - if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) { + if (! R_existsVarInFrame(arrow::r::ns::arrow, r6_class)) { cpp11::stop("No arrow R6 class named '%s'", r6_class_name); } From 1ce25428305be4c8f8a6caa4019154aa797e0f33 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sat, 6 Jul 2024 21:27:04 -0500 Subject: [PATCH 2/4] Remove LEVELS --- r/src/arrow_cpp11.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index eacddd08773..660b917ffef 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -44,9 +44,6 @@ #define UTF8_MASK (1 << 3) #define ASCII_MASK (1 << 6) -#define IS_ASCII(x) (LEVELS(x) & ASCII_MASK) -#define IS_UTF8(x) (LEVELS(x) & UTF8_MASK) - // For context, see: // https://github.com/r-devel/r-svn/blob/6418faeb6f5d87d3d9b92b8978773bc3856b4b6f/src/main/altrep.c#L37 #define ALTREP_CLASS_SERIALIZED_CLASS(x) ATTRIB(x) @@ -134,18 +131,12 @@ class complexs { namespace unsafe { inline const char* utf8_string(SEXP s) { - if (!IS_UTF8(s) && !IS_ASCII(s)) { - return Rf_translateCharUTF8(s); - } else { - return CHAR(s); - } + return Rf_translateCharUTF8(s); } inline R_xlen_t r_string_size(SEXP s) { if (s == NA_STRING) { return 0; - } else if (IS_ASCII(s) || IS_UTF8(s)) { - return XLENGTH(s); } else { return strlen(Rf_translateCharUTF8(s)); } @@ -164,7 +155,7 @@ inline SEXP utf8_strings(SEXP x) { for (R_xlen_t i = 0; i < n; i++, ++p_x) { SEXP s = *p_x; - if (s != NA_STRING && !IS_UTF8(s) && !IS_ASCII(s)) { + if (s != NA_STRING) { SET_STRING_ELT(x, i, Rf_mkCharCE(Rf_translateCharUTF8(s), CE_UTF8)); } } From cb204d5f7995ea51871daa1b069e7b2f2c34705e Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sun, 7 Jul 2024 07:46:26 -0500 Subject: [PATCH 3/4] lint --- r/src/arrow_cpp11.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 660b917ffef..acd692f4cb6 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -130,9 +130,7 @@ class complexs { // functions that need to be called from an unwind_protect() namespace unsafe { -inline const char* utf8_string(SEXP s) { - return Rf_translateCharUTF8(s); -} +inline const char* utf8_string(SEXP s) { return Rf_translateCharUTF8(s); } inline R_xlen_t r_string_size(SEXP s) { if (s == NA_STRING) { @@ -385,7 +383,7 @@ SEXP to_r6(const std::shared_ptr& ptr, const char* r6_class_name) { cpp11::external_pointer> xp(new std::shared_ptr(ptr)); SEXP r6_class = Rf_install(r6_class_name); - if (! R_existsVarInFrame(arrow::r::ns::arrow, r6_class)) { + if (!R_existsVarInFrame(arrow::r::ns::arrow, r6_class)) { cpp11::stop("No arrow R6 class named '%s'", r6_class_name); } From 975102c67a01b656a3654e1463487874c18f507e Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sun, 7 Jul 2024 08:42:49 -0500 Subject: [PATCH 4/4] Ooops, delete two more --- r/src/arrow_cpp11.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index acd692f4cb6..5e6a7d5a42f 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -39,11 +39,6 @@ #define ARROW_R_DCHECK(EXPR) #endif -// borrowed from enc package -// because R does not make these macros available (i.e. from Defn.h) -#define UTF8_MASK (1 << 3) -#define ASCII_MASK (1 << 6) - // For context, see: // https://github.com/r-devel/r-svn/blob/6418faeb6f5d87d3d9b92b8978773bc3856b4b6f/src/main/altrep.c#L37 #define ALTREP_CLASS_SERIALIZED_CLASS(x) ATTRIB(x)