Reduce memory footprint.

This commit is contained in:
Naoki INADA 2009-06-24 01:54:47 +09:00
parent 3fd28d0792
commit f61b282886
2 changed files with 7 additions and 6 deletions

View File

@ -23,9 +23,7 @@
#define MSGPACK_MAX_STACK_SIZE (1024) #define MSGPACK_MAX_STACK_SIZE (1024)
#include "unpack_define.h" #include "unpack_define.h"
using namespace std; typedef std::map<std::string, PyObject*> str_cach_t;
typedef map<string, PyObject*> str_cach_t;
struct unpack_user { struct unpack_user {
str_cach_t strcache; str_cach_t strcache;
@ -127,7 +125,7 @@ static inline int template_callback_map_item(unpack_user* u, msgpack_unpack_obje
static inline int template_callback_raw(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_unpack_object* o) static inline int template_callback_raw(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_unpack_object* o)
{ {
if (l < 16) { if (l < 16) {
string s(p, l); std::string s(p, l);
str_cach_t ::iterator it = u->strcache.find(s); str_cach_t ::iterator it = u->strcache.find(s);
if (it != u->strcache.end()) { if (it != u->strcache.end()) {
*o = it->second; *o = it->second;

View File

@ -43,11 +43,14 @@
msgpack_unpack_struct_decl(_stack) { msgpack_unpack_struct_decl(_stack) {
msgpack_unpack_object obj; msgpack_unpack_object obj;
size_t curr;
size_t count; size_t count;
unsigned int ct; unsigned int ct;
union {
size_t curr;
msgpack_unpack_object map_key; msgpack_unpack_object map_key;
}; };
};
msgpack_unpack_struct_decl(_context) { msgpack_unpack_struct_decl(_context) {
msgpack_unpack_user user; msgpack_unpack_user user;