Make CHECKs with char*s do what you mean.
char*s are pointers in CHECKs, not 1970s-style strings.
Also fix an unnecessary std::string copy and remove two unused #includes.
Change-Id: I0045878f86e15c4f1d0fd4f61953334e826eb75c
diff --git a/src/hprof/hprof.cc b/src/hprof/hprof.cc
index c90ccf0..66cb24d 100644
--- a/src/hprof/hprof.cc
+++ b/src/hprof/hprof.cc
@@ -31,8 +31,6 @@
#include "object.h"
#include "object_utils.h"
#include "stringprintf.h"
-#include "unordered_map.h"
-#include "unordered_set.h"
#include <cutils/open_memstream.h>
#include <sys/uio.h>
diff --git a/src/logging.h b/src/logging.h
index 9e10bd9..d421552 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -137,6 +137,32 @@
RHS rhs;
};
+// We want char*s to be treated as pointers, not strings. If you want them treated like strings,
+// you'd need to use CHECK_STREQ and CHECK_STRNE anyway to compare the characters rather than their
+// addresses. We could express this more succinctly with std::remove_const, but this is quick and
+// easy to understand, and works before we have C++0x. We rely on signed/unsigned warnings to
+// protect you against combinations not explicitly listed below.
+#define EAGER_PTR_EVALUATOR(T1, T2) \
+ template <> struct EagerEvaluator<T1, T2> { \
+ EagerEvaluator(T1 lhs, T2 rhs) \
+ : lhs(reinterpret_cast<const void*>(lhs)), \
+ rhs(reinterpret_cast<const void*>(rhs)) { } \
+ const void* lhs; \
+ const void* rhs; \
+ }
+EAGER_PTR_EVALUATOR(const char*, const char*);
+EAGER_PTR_EVALUATOR(const char*, char*);
+EAGER_PTR_EVALUATOR(char*, const char*);
+EAGER_PTR_EVALUATOR(char*, char*);
+EAGER_PTR_EVALUATOR(const unsigned char*, const unsigned char*);
+EAGER_PTR_EVALUATOR(const unsigned char*, unsigned char*);
+EAGER_PTR_EVALUATOR(unsigned char*, const unsigned char*);
+EAGER_PTR_EVALUATOR(unsigned char*, unsigned char*);
+EAGER_PTR_EVALUATOR(const signed char*, const signed char*);
+EAGER_PTR_EVALUATOR(const signed char*, signed char*);
+EAGER_PTR_EVALUATOR(signed char*, const signed char*);
+EAGER_PTR_EVALUATOR(signed char*, signed char*);
+
// This indirection greatly reduces the stack impact of having
// lots of checks/logging in a function.
struct LogMessageData {
diff --git a/src/oat_file.cc b/src/oat_file.cc
index 646f1c5..a4bbc5f 100644
--- a/src/oat_file.cc
+++ b/src/oat_file.cc
@@ -163,7 +163,7 @@
}
OatFile::OatDexFile::OatDexFile(const OatFile* oat_file,
- std::string dex_file_location,
+ const std::string& dex_file_location,
uint32_t dex_file_checksum,
byte* dex_file_pointer,
const uint32_t* oat_class_offsets_pointer)
diff --git a/src/oat_file.h b/src/oat_file.h
index 5c011fd..33a0e28 100644
--- a/src/oat_file.h
+++ b/src/oat_file.h
@@ -151,7 +151,7 @@
~OatDexFile();
private:
OatDexFile(const OatFile* oat_file,
- std::string dex_file_location,
+ const std::string& dex_file_location,
uint32_t dex_file_checksum,
byte* dex_file_pointer,
const uint32_t* oat_class_offsets_pointer);