From cd7e2df37ef2dcd8271124d467f89ba9944576bc Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 7 Sep 2013 13:48:55 +0000 Subject: [PATCH] switched Sha1CheckSum::toStdString() to simpler/faster code. checked with tests/util/sha1_test git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6707 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/util/rsdir.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/util/rsdir.cc b/libretroshare/src/util/rsdir.cc index 367a9d24f..a13742015 100644 --- a/libretroshare/src/util/rsdir.cc +++ b/libretroshare/src/util/rsdir.cc @@ -672,11 +672,20 @@ bool Sha1CheckSum::operator==(const Sha1CheckSum& s) const std::string Sha1CheckSum::toStdString() const { - std::string tmpout; + static const char outl[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' } ; + std::string tmpout(40,' '); for(int i = 0; i < 5; i++) for(int j = 0; j < 4; j++) - rs_sprintf_append(tmpout, "%02x", ((fourbytes[i] >> (8*j)) & 0xff )); + { + int k = j + i*4 ; + uint8_t byte = (fourbytes[i] >> (8*j)) & 0xff ; + + tmpout[2*k ] = outl[ (byte>>4) ] ; + tmpout[2*k+1] = outl[ byte & 0xf ] ; + + //rs_sprintf_append(tmpout, "%02x", ((fourbytes[i] >> (8*j)) & 0xff )); + } return tmpout; }