Skip to content
Snippets Groups Projects
Commit 0e032244 authored by despair's avatar despair
Browse files

namespace rename

parent 30b2a955
No related branches found
No related tags found
No related merge requests found
No preview for this file type
File added
......@@ -18,10 +18,13 @@ CFGFileParser::~CFGFileParser()
tlsf_free(buffer);
}
namespace despair{
namespace ntr{
size_t string_hash(const fast_string &str)
{
size_t out = 0;
// instead of tying this to i386/amd64
// because someone is eventually going to
// port this to ARM or some RISC nonsense
#if UINTPTR_MAX == 0xffffffff
MurmurHash3_x86_128 ( &str, sizeof(str), 7904542L, &out );
#elif UINTPTR_MAX == 0xffffffffffffffff
......
......@@ -12,9 +12,9 @@
#include <cstdint>
// let's try fast strings
typedef std::basic_string<char, std::char_traits<char>, despair::TLSFAlloc<char>> fast_string;
namespace despair{ size_t string_hash(const fast_string &str); bool fast_string_compare(fast_string t1, fast_string t2); }
typedef std::unordered_map<fast_string,fast_string,std::function<decltype(despair::string_hash)>,std::function<decltype(despair::fast_string_compare)>,despair::TLSFAlloc<std::pair<const fast_string, fast_string>>> stringmap;
typedef std::basic_string<char, std::char_traits<char>, ntr::TLSFAlloc<char>> fast_string;
namespace ntr{ size_t string_hash(const fast_string &str); bool fast_string_compare(fast_string t1, fast_string t2); }
typedef std::unordered_map<fast_string,fast_string,std::function<decltype(ntr::string_hash)>,std::function<decltype(ntr::fast_string_compare)>,ntr::TLSFAlloc<std::pair<const fast_string, fast_string>>> stringmap;
// Class which holds the parsed configuration options after
// being processed by CFGFileParser. No longer a "trivial class"
......@@ -22,8 +22,14 @@ typedef std::unordered_map<fast_string,fast_string,std::function<decltype(despai
struct BrowserConfiguration{
stringmap GlobalSettings;
// fast allocation!
static void* operator new(std::size_t n) { if (void *mem = tlsf_malloc(n)) return mem; throw std::bad_alloc {}; }
static void operator delete(void *p){tlsf_free(p);}
static void* operator new(std::size_t n){
if (void *mem = tlsf_malloc(n)){
return mem;
} throw std::bad_alloc {};
}
static void operator delete(void *p){
tlsf_free(p);
}
void clear();
};
......
......@@ -6,7 +6,7 @@
#include <iostream>
#include "tlsf.h"
namespace despair {
namespace ntr {
template <class T>
class TLSFAlloc {
public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment