Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #188 #189

Merged
merged 4 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ Imports:
vctrs (>= 0.4.2),
zip,
tools
LinkingTo:
cpp11 (>= 0.4.6)
Suggests:
spelling,
testthat,
Expand All @@ -43,7 +41,7 @@ Suggests:
withr,
readr (>= 1.2.1)
License: GPL-3
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Encoding: UTF-8
VignetteBuilder: knitr
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# readODS 2.2.0.999

* Use `minty` instead of `readr` to reduce the number of dependencies
* Fix #173, Use a modified vendored version of `cpp11` to avoid the "non-API calls"

## Bug fixes

* Fix #185 - `trim_ws` for `colnames` behaves the same as `readxl::read_xlsx()`.
Expand Down
4 changes: 2 additions & 2 deletions benchmark/issue81_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
date()
```

[1] "Thu May 23 09:29:23 2024"
[1] "Sun May 26 08:53:10 2024"

``` r
devtools::load_all()
Expand All @@ -19,7 +19,7 @@ system.time(x <- read_ods(file, sheet = 2, skip = 4))
```

user system elapsed
0.375 0.072 0.446
0.369 0.076 0.447

``` r
dim(x)
Expand Down
10 changes: 5 additions & 5 deletions benchmark/roundtrip.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ Let’s break it down
date()
```

[1] "Thu May 23 09:28:23 2024"
[1] "Sun May 26 08:52:11 2024"

``` r
library(nycflights13)
system.time(path <- writexl::write_xlsx(flights))
```

user system elapsed
6.156 0.296 6.460
6.253 0.256 6.539

``` r
system.time(out <- readxl::read_xlsx(path))
```

user system elapsed
2.168 0.625 2.800
2.166 0.632 2.820

``` r
all.equal(out, flights)
Expand All @@ -52,14 +52,14 @@ system.time(path <- readODS::write_ods(flights))
```

user system elapsed
13.493 0.360 13.912
13.197 0.507 13.808

``` r
system.time(out <- readODS::read_ods(path))
```

user system elapsed
27.568 1.740 29.362
26.976 1.752 28.813

``` r
all.equal(out, flights)
Expand Down
6 changes: 3 additions & 3 deletions benchmark/tidyodsexample.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
date()
```

[1] "Thu May 23 09:29:18 2024"
[1] "Sun May 26 08:53:05 2024"

``` r
devtools::load_all()
Expand All @@ -23,7 +23,7 @@ bench::mark("readODS" = read_ods(file, sheet = 2), check = FALSE, filter_gc = FA
# A tibble: 1 × 4
expression min median mean
<bch:expr> <bch:tm> <bch:tm> <bch:tm>
1 readODS 5.01ms 5.29ms 7.83ms
1 readODS 5.2ms 5.36ms 7.67ms

``` r
postcodes_file <- here::here("benchmark/civil-service-postcodes-2021.ods")
Expand Down Expand Up @@ -52,4 +52,4 @@ bench::mark("readODS" = readODS::read_ods(postcodes_file, 2), check = FALSE, fil
# A tibble: 1 × 4
expression min median mean
<bch:expr> <bch:tm> <bch:tm> <bch:tm>
1 readODS 425ms 444ms 445ms
1 readODS 420ms 428ms 430ms
6 changes: 3 additions & 3 deletions benchmark/write_ods.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
date()
```

[1] "Thu May 23 09:29:28 2024"
[1] "Sun May 26 08:53:15 2024"

``` r
devtools::load_all()
Expand All @@ -28,7 +28,7 @@ system.time(write_ods(df1, path = tempfile(fileext = ".ods")))
```

user system elapsed
0.043 0.004 0.062
0.042 0.004 0.052

Large df

Expand All @@ -37,7 +37,7 @@ system.time(write_ods(nycflights13::flights))
```

user system elapsed
14.517 0.484 15.222
14.147 0.584 14.910

``` r
sessionInfo()
Expand Down
8 changes: 4 additions & 4 deletions benchmark/write_ods_apend.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
date()
```

[1] "Thu May 23 09:29:25 2024"
[1] "Sun May 26 08:53:12 2024"

``` r
devtools::load_all()
Expand All @@ -30,21 +30,21 @@ system.time(write_ods(df1, path = path, sheet = "aaaa", append = TRUE))
```

user system elapsed
0.254 0.020 0.290
0.251 0.024 0.275

``` r
system.time(write_ods(df1, path = path, sheet = "aaaa", update = TRUE))
```

user system elapsed
0.332 0.020 0.367
0.321 0.032 0.365

``` r
system.time(write_ods(mtcars, path = path, sheet = "aaaa", update = TRUE))
```

user system elapsed
0.225 0.012 0.249
0.217 0.020 0.239

``` r
sessionInfo()
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ comment: false
coverage:
status:
patch: off
ignore:
- inst/include
26 changes: 26 additions & 0 deletions inst/include/cpp11.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// cpp11 version: 0.4.7
// vendored on: 2024-05-26
#pragma once

#include "cpp11/R.hpp"
#include "cpp11/altrep.hpp"
#include "cpp11/as.hpp"
#include "cpp11/attribute_proxy.hpp"
#include "cpp11/data_frame.hpp"
#include "cpp11/doubles.hpp"
#include "cpp11/environment.hpp"
#include "cpp11/external_pointer.hpp"
#include "cpp11/function.hpp"
#include "cpp11/integers.hpp"
#include "cpp11/list.hpp"
#include "cpp11/list_of.hpp"
#include "cpp11/logicals.hpp"
#include "cpp11/matrix.hpp"
#include "cpp11/named_arg.hpp"
#include "cpp11/protect.hpp"
#include "cpp11/r_bool.hpp"
#include "cpp11/r_string.hpp"
#include "cpp11/r_vector.hpp"
#include "cpp11/raws.hpp"
#include "cpp11/sexp.hpp"
#include "cpp11/strings.hpp"
63 changes: 63 additions & 0 deletions inst/include/cpp11/R.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// cpp11 version: 0.4.7
// vendored on: 2024-05-26
#pragma once

#ifdef R_INTERNALS_H_
#if !(defined(R_NO_REMAP) && defined(STRICT_R_HEADERS))
#error R headers were included before cpp11 headers \
and at least one of R_NO_REMAP or STRICT_R_HEADERS \
was not defined.
#endif
#endif

#define R_NO_REMAP
#define STRICT_R_HEADERS
#include "Rinternals.h"

// clang-format off
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wattributes"
#endif

#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wattributes"
#endif
// clang-format on

#include <type_traits>
#include "cpp11/altrep.hpp"

namespace cpp11 {
namespace literals {

constexpr R_xlen_t operator"" _xl(unsigned long long int value) { return value; }

} // namespace literals

namespace traits {
template <typename T>
struct get_underlying_type {
using type = T;
};
} // namespace traits

template <typename T>
inline T na();

template <typename T>
inline typename std::enable_if<!std::is_same<typename std::decay<T>::type, double>::value,
bool>::type
is_na(const T& value) {
return value == na<T>();
}

template <typename T>
inline typename std::enable_if<std::is_same<typename std::decay<T>::type, double>::value,
bool>::type
is_na(const T& value) {
return ISNA(value);
}

} // namespace cpp11
44 changes: 44 additions & 0 deletions inst/include/cpp11/altrep.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// cpp11 version: 0.4.7
// vendored on: 2024-05-26
#pragma once

#include "Rversion.h"

#if defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0)
#define HAS_ALTREP
#endif

#ifndef HAS_ALTREP

#define ALTREP(x) false

#define REAL_ELT(x, i) REAL(x)[i]
#define INTEGER_ELT(x, i) INTEGER(x)[i]
#define LOGICAL_ELT(x, i) LOGICAL(x)[i]
#define RAW_ELT(x, i) RAW(x)[i]

#define SET_REAL_ELT(x, i, val) REAL(x)[i] = val
#define SET_INTEGER_ELT(x, i, val) INTEGER(x)[i] = val
#define SET_LOGICAL_ELT(x, i, val) LOGICAL(x)[i] = val
#define SET_RAW_ELT(x, i, val) RAW(x)[i] = val

#define REAL_GET_REGION(...) \
do { \
} while (false)

#define INTEGER_GET_REGION(...) \
do { \
} while (false)
#endif

#if !defined HAS_ALTREP || (defined(R_VERSION) && R_VERSION < R_Version(3, 6, 0))

#define LOGICAL_GET_REGION(...) \
do { \
} while (false)

#define RAW_GET_REGION(...) \
do { \
} while (false)

#endif
Loading
Loading