Skip to content

Commit

Permalink
Merge pull request #9 from eddelbuettel/feature/small_refactor
Browse files Browse the repository at this point in the history
Small simplification removing extra layer (closes #8)
  • Loading branch information
lsilvest committed Mar 23, 2023
2 parents ea49578 + f924615 commit a5fbcfe
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 67 deletions.
6 changes: 5 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

* src/Makevars: Removed as we do not set a compilation standard

2022-08-21 Dirk Eddelbuettel <edd@debian.org>

* src/align.cpp (align_{,idx}_{duration,period}): Small simplification

2022-03-10 Dirk Eddelbuettel <edd@debian.org>

* README.md: Add badges, polish one example (thanks, @janogorecki)
* README.md: Add badges, polish one example (thanks, @jangorecki)

2022-03-06 Dirk Eddelbuettel <edd@debian.org>

Expand Down
104 changes: 38 additions & 66 deletions src/align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,23 +346,16 @@ Rcpp::List align_duration(const Rcpp::NumericVector& x, // nanotime vect
const Rcpp::LogicalVector& eopen, // end open
const Rcpp::Function func) // function to apply (character)
{
try {
return align_func_duration(reinterpret_cast<const nanotime::dtime*>(&x[0]),
x.size(),
reinterpret_cast<const nanotime::dtime*>(&y[0]),
y.size(),
xdata,
ConstPseudoVectorDuration(start),
ConstPseudoVectorDuration(end),
ConstPseudoVectorLgl(sopen),
ConstPseudoVectorLgl(eopen),
Rcpp::Function(func));
} catch(std::exception &ex) {
forward_exception_to_r(ex);
} catch(...) {
::Rf_error("c++ exception (unknown reason)");
}
return R_NilValue; // not reached
return align_func_duration(reinterpret_cast<const nanotime::dtime*>(&x[0]),
x.size(),
reinterpret_cast<const nanotime::dtime*>(&y[0]),
y.size(),
xdata,
ConstPseudoVectorDuration(start),
ConstPseudoVectorDuration(end),
ConstPseudoVectorLgl(sopen),
ConstPseudoVectorLgl(eopen),
Rcpp::Function(func));
}


Expand All @@ -377,24 +370,17 @@ Rcpp::List align_period(const Rcpp::NumericVector& x, // nanotime vector
const Rcpp::Function func, // function to apply (character)
const Rcpp::CharacterVector tz) // timezone
{
try {
return align_func_period(reinterpret_cast<const nanotime::dtime*>(&x[0]),
x.size(),
reinterpret_cast<const nanotime::dtime*>(&y[0]),
y.size(),
xdata,
ConstPseudoVectorPrd(start),
ConstPseudoVectorPrd(end),
ConstPseudoVectorLgl(sopen),
ConstPseudoVectorLgl(eopen),
Rcpp::Function(func),
ConstPseudoVectorChar(tz));
} catch(std::exception &ex) {
forward_exception_to_r(ex);
} catch(...) {
::Rf_error("c++ exception (unknown reason)");
}
return R_NilValue; // not reached
return align_func_period(reinterpret_cast<const nanotime::dtime*>(&x[0]),
x.size(),
reinterpret_cast<const nanotime::dtime*>(&y[0]),
y.size(),
xdata,
ConstPseudoVectorPrd(start),
ConstPseudoVectorPrd(end),
ConstPseudoVectorLgl(sopen),
ConstPseudoVectorLgl(eopen),
Rcpp::Function(func),
ConstPseudoVectorChar(tz));
}


Expand All @@ -406,21 +392,14 @@ Rcpp::NumericVector align_idx_duration(const Rcpp::NumericVector& x, // nano
const Rcpp::LogicalVector& sopen, // start open
const Rcpp::LogicalVector& eopen) // end open
{
try {
return align_idx_helper_duration(reinterpret_cast<const nanotime::dtime*>(&x[0]),
x.size(),
reinterpret_cast<const nanotime::dtime*>(&y[0]),
y.size(),
ConstPseudoVectorDuration(start),
ConstPseudoVectorDuration(end),
ConstPseudoVectorLgl(sopen),
ConstPseudoVectorLgl(eopen));
} catch(std::exception &ex) {
forward_exception_to_r(ex);
} catch(...) {
::Rf_error("c++ exception (unknown reason)");
}
return R_NilValue; // not reached
return align_idx_helper_duration(reinterpret_cast<const nanotime::dtime*>(&x[0]),
x.size(),
reinterpret_cast<const nanotime::dtime*>(&y[0]),
y.size(),
ConstPseudoVectorDuration(start),
ConstPseudoVectorDuration(end),
ConstPseudoVectorLgl(sopen),
ConstPseudoVectorLgl(eopen));
}


Expand All @@ -433,22 +412,15 @@ Rcpp::NumericVector align_idx_period(const Rcpp::NumericVector& x, // nanoti
const Rcpp::LogicalVector& eopen, // end open
const Rcpp::CharacterVector& tz) // timezone
{
try {
return align_idx_helper_period(reinterpret_cast<const nanotime::dtime*>(&x[0]),
x.size(),
reinterpret_cast<const nanotime::dtime*>(&y[0]),
y.size(),
ConstPseudoVectorPrd(start),
ConstPseudoVectorPrd(end),
ConstPseudoVectorLgl(sopen),
ConstPseudoVectorLgl(eopen),
ConstPseudoVectorChar(tz));
} catch(std::exception &ex) {
forward_exception_to_r(ex);
} catch(...) {
::Rf_error("c++ exception (unknown reason)");
}
return R_NilValue; // not reached
return align_idx_helper_period(reinterpret_cast<const nanotime::dtime*>(&x[0]),
x.size(),
reinterpret_cast<const nanotime::dtime*>(&y[0]),
y.size(),
ConstPseudoVectorPrd(start),
ConstPseudoVectorPrd(end),
ConstPseudoVectorLgl(sopen),
ConstPseudoVectorLgl(eopen),
ConstPseudoVectorChar(tz));
}


Expand Down

0 comments on commit a5fbcfe

Please sign in to comment.