diff options
author | gabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529> | 2011-07-21 02:40:18 +0000 |
---|---|---|
committer | gabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529> | 2011-07-21 02:40:18 +0000 |
commit | 60bd8015f21fdb63d5409b1191f8ea9d8f1a1b87 (patch) | |
tree | dab21fd0d1309be4e6851f690e1c011e79ddbf6b /port/port_posix.h | |
parent | 6872ace90110799f87402cbc594c4cbf1bc474c7 (diff) | |
download | leveldb-60bd8015f21fdb63d5409b1191f8ea9d8f1a1b87.tar.gz |
Speed up Snappy uncompression, new Logger interface.
- Removed one copy of an uncompressed block contents changing
the signature of Snappy_Uncompress() so it uncompresses into a
flat array instead of a std::string.
Speeds up readrandom ~10%.
- Instead of a combination of Env/WritableFile, we now have a
Logger interface that can be easily overridden applications
that want to supply their own logging.
- Separated out the gcc and Sun Studio parts of atomic_pointer.h
so we can use 'asm', 'volatile' keywords for Sun Studio.
git-svn-id: https://leveldb.googlecode.com/svn/trunk@39 62dab493-f737-651d-591e-8d6aee1b9529
Diffstat (limited to 'port/port_posix.h')
-rw-r--r-- | port/port_posix.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/port/port_posix.h b/port/port_posix.h index 2995026..ef01de3 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -80,12 +80,12 @@ class CondVar { Mutex* mu_; }; -inline bool Snappy_Compress(const char* input, size_t input_length, +inline bool Snappy_Compress(const char* input, size_t length, ::std::string* output) { #ifdef SNAPPY - output->resize(snappy::MaxCompressedLength(input_length)); + output->resize(snappy::MaxCompressedLength(length)); size_t outlen; - snappy::RawCompress(input, input_length, &(*output)[0], &outlen); + snappy::RawCompress(input, length, &(*output)[0], &outlen); output->resize(outlen); return true; #endif @@ -93,18 +93,22 @@ inline bool Snappy_Compress(const char* input, size_t input_length, return false; } -inline bool Snappy_Uncompress(const char* input_data, size_t input_length, - ::std::string* output) { +inline bool Snappy_GetUncompressedLength(const char* input, size_t length, + size_t* result) { #ifdef SNAPPY - size_t ulength; - if (!snappy::GetUncompressedLength(input_data, input_length, &ulength)) { - return false; - } - output->resize(ulength); - return snappy::RawUncompress(input_data, input_length, &(*output)[0]); + return snappy::GetUncompressedLength(input, length, result); +#else + return false; #endif +} +inline bool Snappy_Uncompress(const char* input, size_t length, + char* output) { +#ifdef SNAPPY + return snappy::RawUncompress(input, length, output); +#else return false; +#endif } inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { |