ringct: avoid unnecessary memcpy

This commit is contained in:
moneromooo-monero 2016-10-10 23:37:02 +01:00
parent 1fe75c1ea7
commit 9ebf7b6dcf
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 3 additions and 16 deletions

View File

@ -368,15 +368,8 @@ namespace rct {
//This takes the outputs and commitments //This takes the outputs and commitments
//and hashes them into a 32 byte sized key //and hashes them into a 32 byte sized key
key cn_fast_hash(const ctkeyV &PC) { key cn_fast_hash(const ctkeyV &PC) {
key rv = identity(); key rv;
std::size_t l = (std::size_t)PC.size(); cn_fast_hash(rv, &PC[0], 64*PC.size());
size_t i = 0, j = 0;
vector<char> m(l * 64);
for (i = 0 ; i < l ; i++) {
memcpy(&m[i * 64], &PC[i].dest, 32);
memcpy(&m[i * 64 + 32], &PC[i].mask, 32);
}
cn_fast_hash(rv, &m[0], 64*l);
return rv; return rv;
} }
@ -391,14 +384,8 @@ namespace rct {
//put them in the key vector and it concatenates them //put them in the key vector and it concatenates them
//and then hashes them //and then hashes them
key cn_fast_hash(const keyV &keys) { key cn_fast_hash(const keyV &keys) {
size_t l = keys.size();
vector<unsigned char> m(l * 32);
size_t i;
for (i = 0 ; i < l ; i++) {
memcpy(&m[i * 32], keys[i].bytes, 32);
}
key rv; key rv;
cn_fast_hash(rv, &m[0], 32 * l); cn_fast_hash(rv, &keys[0], keys.size() * sizeof(keys[0]));
//dp(rv); //dp(rv);
return rv; return rv;
} }