Browse Source

namespace rename

master
despair 5 years ago
parent
commit
0e032244a1
  1. BIN
      deps/lib/nt_i386/release/libbz2.a
  2. BIN
      deps/lib/nt_i386/release/libglfw-nt.a
  3. 5
      src/CFGFileParser.cpp
  4. 16
      src/CFGFileParser.h
  5. 2
      src/TLSFAlloc.h

BIN
deps/lib/nt_i386/release/libbz2.a vendored

Binary file not shown.

BIN
deps/lib/nt_i386/release/libglfw-nt.a vendored

Binary file not shown.

5
src/CFGFileParser.cpp

@ -18,10 +18,13 @@ CFGFileParser::~CFGFileParser() @@ -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

16
src/CFGFileParser.h

@ -12,9 +12,9 @@ @@ -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 @@ -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();
};

2
src/TLSFAlloc.h

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
#include <iostream>
#include "tlsf.h"
namespace despair {
namespace ntr {
template <class T>
class TLSFAlloc {
public:

Loading…
Cancel
Save