Skip to content

Commit

Permalink
Merge pull request #55 from chainsawriot/decode2
Browse files Browse the repository at this point in the history
Decode in c++
  • Loading branch information
schochastics authored Oct 3, 2023
2 parents b13f729 + 5c2c416 commit ba3392c
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 143 deletions.
44 changes: 22 additions & 22 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

Rcpp_ada_parse <- function(input_vec) {
.Call(`_adaR_Rcpp_ada_parse`, input_vec)
Rcpp_ada_parse <- function(input_vec, decode) {
.Call(`_adaR_Rcpp_ada_parse`, input_vec, decode)
}

Rcpp_ada_has_credentials <- function(url_vec) {
Expand Down Expand Up @@ -37,44 +37,44 @@ Rcpp_ada_has_search <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_has_search`, url_vec)
}

Rcpp_ada_get_href <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_href`, url_vec)
Rcpp_ada_get_href <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_href`, url_vec, decode)
}

Rcpp_ada_get_username <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_username`, url_vec)
Rcpp_ada_get_username <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_username`, url_vec, decode)
}

Rcpp_ada_get_password <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_password`, url_vec)
Rcpp_ada_get_password <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_password`, url_vec, decode)
}

Rcpp_ada_get_port <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_port`, url_vec)
Rcpp_ada_get_port <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_port`, url_vec, decode)
}

Rcpp_ada_get_hash <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_hash`, url_vec)
Rcpp_ada_get_hash <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_hash`, url_vec, decode)
}

Rcpp_ada_get_host <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_host`, url_vec)
Rcpp_ada_get_host <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_host`, url_vec, decode)
}

Rcpp_ada_get_hostname <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_hostname`, url_vec)
Rcpp_ada_get_hostname <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_hostname`, url_vec, decode)
}

Rcpp_ada_get_pathname <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_pathname`, url_vec)
Rcpp_ada_get_pathname <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_pathname`, url_vec, decode)
}

Rcpp_ada_get_search <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_search`, url_vec)
Rcpp_ada_get_search <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_search`, url_vec, decode)
}

Rcpp_ada_get_protocol <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_protocol`, url_vec)
Rcpp_ada_get_protocol <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_protocol`, url_vec, decode)
}

Rcpp_url_decode2 <- function(url) {
Expand Down
15 changes: 9 additions & 6 deletions R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
if (is.null(url)) {
return(character(0))
}
out <- func(url)
if (isTRUE(decode)) {
return(url_decode2(out))
}
return(out)
func(url, decode)
}

#' Get a specific component of URL
Expand Down Expand Up @@ -110,5 +106,12 @@ R_ada_get_domain <- function(url) {
#' @rdname ada_get_href
#' @export
ada_get_domain <- function(url, decode = TRUE) {
.get(url, decode, R_ada_get_domain)
if (is.null(url)) {
return(character(0))
}
res <- R_ada_get_domain(url)
if (decode) {
return(url_decode2(res))
}
return(res)
}
24 changes: 1 addition & 23 deletions R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,7 @@ ada_url_parse <- function(url, decode = TRUE) {
search = character(0), hash = character(0)
), row.names = integer(0), class = "data.frame"))
}
url_parsed <- Rcpp_ada_parse(url)
if (isTRUE(decode)) {
return(.decoder(url_parsed))
}
return(url_parsed)
}

.decoder <- function(df) {
for (i in seq_len(ncol(df))) {
df[[i]] <- .URLdecode(df[[i]])
}
df
Rcpp_ada_parse(url, decode)
}

#' Function to percent-decode characters in URLs
Expand All @@ -46,14 +35,3 @@ url_decode2 <- function(url) {
}
Rcpp_url_decode2(url)
}

## NA/NULL-aware utils::URLdecode, hopefully without great performance impact
.URLdecode <- function(URL) {
if (is.null(URL)) {
return(character(0))
}
non_na_index <- which(!is.na(URL))
URL[non_na_index] <- url_decode2(URL[non_na_index])
URL[!non_na_index] <- NA_character_
return(URL)
}
99 changes: 55 additions & 44 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// Rcpp_ada_parse
DataFrame Rcpp_ada_parse(const CharacterVector& input_vec);
RcppExport SEXP _adaR_Rcpp_ada_parse(SEXP input_vecSEXP) {
DataFrame Rcpp_ada_parse(const CharacterVector& input_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_parse(SEXP input_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type input_vec(input_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_parse(input_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_parse(input_vec, decode));
return rcpp_result_gen;
END_RCPP
}
Expand Down Expand Up @@ -110,112 +111,122 @@ BEGIN_RCPP
END_RCPP
}
// Rcpp_ada_get_href
CharacterVector Rcpp_ada_get_href(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_href(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_href(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_href(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_href(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_href(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_get_username
CharacterVector Rcpp_ada_get_username(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_username(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_username(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_username(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_username(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_username(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_get_password
CharacterVector Rcpp_ada_get_password(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_password(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_password(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_password(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_password(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_password(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_get_port
CharacterVector Rcpp_ada_get_port(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_port(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_port(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_port(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_port(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_port(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_get_hash
CharacterVector Rcpp_ada_get_hash(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_hash(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_hash(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_hash(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_hash(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_hash(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_get_host
CharacterVector Rcpp_ada_get_host(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_host(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_host(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_host(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_host(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_host(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_get_hostname
CharacterVector Rcpp_ada_get_hostname(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_hostname(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_hostname(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_hostname(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_hostname(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_hostname(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_get_pathname
CharacterVector Rcpp_ada_get_pathname(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_pathname(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_pathname(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_pathname(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_pathname(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_pathname(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_get_search
CharacterVector Rcpp_ada_get_search(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_search(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_search(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_search(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_search(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_search(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_get_protocol
CharacterVector Rcpp_ada_get_protocol(const CharacterVector& url_vec);
RcppExport SEXP _adaR_Rcpp_ada_get_protocol(SEXP url_vecSEXP) {
CharacterVector Rcpp_ada_get_protocol(const CharacterVector& url_vec, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_get_protocol(SEXP url_vecSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_protocol(url_vec));
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_get_protocol(url_vec, decode));
return rcpp_result_gen;
END_RCPP
}
Expand Down Expand Up @@ -243,7 +254,7 @@ END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"_adaR_Rcpp_ada_parse", (DL_FUNC) &_adaR_Rcpp_ada_parse, 1},
{"_adaR_Rcpp_ada_parse", (DL_FUNC) &_adaR_Rcpp_ada_parse, 2},
{"_adaR_Rcpp_ada_has_credentials", (DL_FUNC) &_adaR_Rcpp_ada_has_credentials, 1},
{"_adaR_Rcpp_ada_has_empty_hostname", (DL_FUNC) &_adaR_Rcpp_ada_has_empty_hostname, 1},
{"_adaR_Rcpp_ada_has_hostname", (DL_FUNC) &_adaR_Rcpp_ada_has_hostname, 1},
Expand All @@ -252,16 +263,16 @@ static const R_CallMethodDef CallEntries[] = {
{"_adaR_Rcpp_ada_has_port", (DL_FUNC) &_adaR_Rcpp_ada_has_port, 1},
{"_adaR_Rcpp_ada_has_hash", (DL_FUNC) &_adaR_Rcpp_ada_has_hash, 1},
{"_adaR_Rcpp_ada_has_search", (DL_FUNC) &_adaR_Rcpp_ada_has_search, 1},
{"_adaR_Rcpp_ada_get_href", (DL_FUNC) &_adaR_Rcpp_ada_get_href, 1},
{"_adaR_Rcpp_ada_get_username", (DL_FUNC) &_adaR_Rcpp_ada_get_username, 1},
{"_adaR_Rcpp_ada_get_password", (DL_FUNC) &_adaR_Rcpp_ada_get_password, 1},
{"_adaR_Rcpp_ada_get_port", (DL_FUNC) &_adaR_Rcpp_ada_get_port, 1},
{"_adaR_Rcpp_ada_get_hash", (DL_FUNC) &_adaR_Rcpp_ada_get_hash, 1},
{"_adaR_Rcpp_ada_get_host", (DL_FUNC) &_adaR_Rcpp_ada_get_host, 1},
{"_adaR_Rcpp_ada_get_hostname", (DL_FUNC) &_adaR_Rcpp_ada_get_hostname, 1},
{"_adaR_Rcpp_ada_get_pathname", (DL_FUNC) &_adaR_Rcpp_ada_get_pathname, 1},
{"_adaR_Rcpp_ada_get_search", (DL_FUNC) &_adaR_Rcpp_ada_get_search, 1},
{"_adaR_Rcpp_ada_get_protocol", (DL_FUNC) &_adaR_Rcpp_ada_get_protocol, 1},
{"_adaR_Rcpp_ada_get_href", (DL_FUNC) &_adaR_Rcpp_ada_get_href, 2},
{"_adaR_Rcpp_ada_get_username", (DL_FUNC) &_adaR_Rcpp_ada_get_username, 2},
{"_adaR_Rcpp_ada_get_password", (DL_FUNC) &_adaR_Rcpp_ada_get_password, 2},
{"_adaR_Rcpp_ada_get_port", (DL_FUNC) &_adaR_Rcpp_ada_get_port, 2},
{"_adaR_Rcpp_ada_get_hash", (DL_FUNC) &_adaR_Rcpp_ada_get_hash, 2},
{"_adaR_Rcpp_ada_get_host", (DL_FUNC) &_adaR_Rcpp_ada_get_host, 2},
{"_adaR_Rcpp_ada_get_hostname", (DL_FUNC) &_adaR_Rcpp_ada_get_hostname, 2},
{"_adaR_Rcpp_ada_get_pathname", (DL_FUNC) &_adaR_Rcpp_ada_get_pathname, 2},
{"_adaR_Rcpp_ada_get_search", (DL_FUNC) &_adaR_Rcpp_ada_get_search, 2},
{"_adaR_Rcpp_ada_get_protocol", (DL_FUNC) &_adaR_Rcpp_ada_get_protocol, 2},
{"_adaR_Rcpp_url_decode2", (DL_FUNC) &_adaR_Rcpp_url_decode2, 1},
{"_adaR_url_reverse", (DL_FUNC) &_adaR_url_reverse, 1},
{NULL, NULL, 0}
Expand Down
Loading

0 comments on commit ba3392c

Please sign in to comment.