fixed feed bug by moving away from std::string as a return type to uniqueIdentifier(). Now uint64_ hash is used and cached

This commit is contained in:
csoler 2019-12-21 14:33:53 +01:00
parent ff86d3cd20
commit 137cb5271d
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
22 changed files with 51 additions and 31 deletions

View file

@ -18,10 +18,11 @@
* *
*******************************************************************************/
#include <iostream>
#include "FeedItem.h"
/** Constructor */
FeedItem::FeedItem(QWidget *parent) : QWidget(parent)
FeedItem::FeedItem(QWidget *parent) : QWidget(parent), mHash(0)
{
mWasExpanded = false;
}
@ -43,3 +44,18 @@ void FeedItem::expand(bool open)
mWasExpanded = true;
}
}
uint64_t FeedItem::hash_64bits(const std::string& s) const
{
if(mHash == 0)
{
mHash = 0x01110bbfa09;
for(uint32_t i=0;i<s.size();++i)
mHash = ~(((mHash << 31) ^ (mHash >> 3)) + s[i]*0x217898fbba7 + 0x0294379);
std::cerr << "Producing hash " << std::hex << mHash << std::dec << " from string \"" << s << "\"" << std::endl;
}
return mHash;
}