Skip to content

Commit

Permalink
micro efficiencies
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Jun 22, 2024
1 parent 4f5af3c commit d4e4b3e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/secret.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ static void mbedtls_sha3_finish(mbedtls_sha3_context *ctx, uint8_t *output, size

// secretbase - internals ------------------------------------------------------

static inline int R_Integer(SEXP x) {
int out;
switch (TYPEOF(x)) {
case INTSXP:
case LGLSXP:
out = *(int * ) DATAPTR_RO(x);
break;
default:
out = Rf_asInteger(x);
}
return out;
}

#if !defined(MBEDTLS_CT_ASM)
static void * (*const volatile secure_memset)(void *, int, size_t) = memset;
#endif
Expand Down Expand Up @@ -325,7 +338,7 @@ static SEXP secretbase_sha3_impl(const SEXP x, const SEXP bits, const SEXP conve
const int offset) {

const int conv = LOGICAL(convert)[0];
const int bt = Rf_asInteger(bits);
const int bt = R_Integer(bits);
mbedtls_sha3_id id;

if (offset < 0) {
Expand Down

0 comments on commit d4e4b3e

Please sign in to comment.