summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaoki INADA <inada-n@klab.jp>2009-06-24 14:58:02 +0900
committerNaoki INADA <inada-n@klab.jp>2009-06-24 14:58:02 +0900
commitb944eefb96a0f3ad907c8fe704fd14ba87384ed5 (patch)
treef745f687dd4f6942a4b978cf7bf3805f00c9332f
parent3eca3d3c68adbc0d3a799faa84c92cb17714db30 (diff)
downloadmsgpack-python-b944eefb96a0f3ad907c8fe704fd14ba87384ed5.tar.gz
Stop unnecessary caching.
-rw-r--r--msgpack/unpack.h44
1 files changed, 5 insertions, 39 deletions
diff --git a/msgpack/unpack.h b/msgpack/unpack.h
index e30b72a..dd23130 100644
--- a/msgpack/unpack.h
+++ b/msgpack/unpack.h
@@ -16,24 +16,10 @@
* limitations under the License.
*/
-#include <map>
-#include <string>
-#include <stack>
-
#define MSGPACK_MAX_STACK_SIZE (1024)
#include "unpack_define.h"
-typedef std::map<std::string, PyObject*> str_cach_t;
struct unpack_user {
- str_cach_t strcache;
-
- ~unpack_user() {
- str_cach_t::iterator it, itend;
- itend = strcache.end();
- for (it = strcache.begin(); it != itend; ++it) {
- Py_DECREF(it->second);
- }
- }
};
@@ -181,31 +167,11 @@ 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)
{
PyObject *py;
- if (l < 16) {
- std::string s(p, l);
- str_cach_t ::iterator it = u->strcache.find(s);
- if (it != u->strcache.end()) {
- *o = it->second;
- Py_INCREF(*o);
- return 0;
- }
- else {
- py = PyString_FromStringAndSize(p, l);
- if (!py)
- return -1;
- *o = py;
- Py_INCREF(*o);
- u->strcache[s] = *o;
- return 0;
- }
- }
- else {
- py = PyString_FromStringAndSize(p, l);
- if (!py)
- return -1;
- *o = py;
- return 0;
- }
+ py = PyString_FromStringAndSize(p, l);
+ if (!py)
+ return -1;
+ *o = py;
+ return 0;
}
#include "unpack_template.h"