summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2013-09-23 09:23:37 -0700
committerIan Rogers <irogers@google.com>2013-09-23 09:25:56 -0700
commita67249065e4c9b3cf4a7c081d95a78df28291ee9 (patch)
tree8f5b84b886362e9f3bb2e9be6b24c2b61a02f907
parent450dcb56ecbf6f729401e753f0a27e4170177ddd (diff)
downloadart-a67249065e4c9b3cf4a7c081d95a78df28291ee9.zip
art-a67249065e4c9b3cf4a7c081d95a78df28291ee9.tar.gz
art-a67249065e4c9b3cf4a7c081d95a78df28291ee9.tar.bz2
Move hot utf routines into -inl.h.
Change-Id: I7050d8282a7e5870b2bf671d6867c57625e00ccc
-rw-r--r--runtime/dex_file.cc2
-rw-r--r--runtime/dex_file_verifier.cc2
-rw-r--r--runtime/mirror/string.cc2
-rw-r--r--runtime/utf-inl.h61
-rw-r--r--runtime/utf.cc36
-rw-r--r--runtime/utf.h5
-rw-r--r--runtime/utils.cc2
7 files changed, 69 insertions, 41 deletions
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index e81c456..098ab67 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -38,7 +38,7 @@
#include "safe_map.h"
#include "thread.h"
#include "UniquePtr.h"
-#include "utf.h"
+#include "utf-inl.h"
#include "utils.h"
#include "well_known_classes.h"
#include "zip_archive.h"
diff --git a/runtime/dex_file_verifier.cc b/runtime/dex_file_verifier.cc
index 5b076e0..7dc2b31 100644
--- a/runtime/dex_file_verifier.cc
+++ b/runtime/dex_file_verifier.cc
@@ -21,7 +21,7 @@
#include "leb128.h"
#include "safe_map.h"
#include "UniquePtr.h"
-#include "utf.h"
+#include "utf-inl.h"
#include "utils.h"
#include "zip_archive.h"
diff --git a/runtime/mirror/string.cc b/runtime/mirror/string.cc
index b82683e..9c93f17 100644
--- a/runtime/mirror/string.cc
+++ b/runtime/mirror/string.cc
@@ -24,7 +24,7 @@
#include "runtime.h"
#include "sirt_ref.h"
#include "thread.h"
-#include "utf.h"
+#include "utf-inl.h"
namespace art {
namespace mirror {
diff --git a/runtime/utf-inl.h b/runtime/utf-inl.h
new file mode 100644
index 0000000..d8c258b
--- /dev/null
+++ b/runtime/utf-inl.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_RUNTIME_UTF_INL_H_
+#define ART_RUNTIME_UTF_INL_H_
+
+#include "utf.h"
+
+namespace art {
+
+inline uint16_t GetUtf16FromUtf8(const char** utf8_data_in) {
+ uint8_t one = *(*utf8_data_in)++;
+ if ((one & 0x80) == 0) {
+ // one-byte encoding
+ return one;
+ }
+ // two- or three-byte encoding
+ uint8_t two = *(*utf8_data_in)++;
+ if ((one & 0x20) == 0) {
+ // two-byte encoding
+ return ((one & 0x1f) << 6) | (two & 0x3f);
+ }
+ // three-byte encoding
+ uint8_t three = *(*utf8_data_in)++;
+ return ((one & 0x0f) << 12) | ((two & 0x3f) << 6) | (three & 0x3f);
+}
+
+inline int CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(const char* utf8_1,
+ const char* utf8_2) {
+ for (;;) {
+ if (*utf8_1 == '\0') {
+ return (*utf8_2 == '\0') ? 0 : -1;
+ } else if (*utf8_2 == '\0') {
+ return 1;
+ }
+
+ int c1 = GetUtf16FromUtf8(&utf8_1);
+ int c2 = GetUtf16FromUtf8(&utf8_2);
+
+ if (c1 != c2) {
+ return c1 > c2 ? 1 : -1;
+ }
+ }
+}
+
+} // namespace art
+
+#endif // ART_RUNTIME_UTF_INL_H_
diff --git a/runtime/utf.cc b/runtime/utf.cc
index 1add7d9..5ec2ea1 100644
--- a/runtime/utf.cc
+++ b/runtime/utf.cc
@@ -19,6 +19,7 @@
#include "base/logging.h"
#include "mirror/array.h"
#include "mirror/object-inl.h"
+#include "utf-inl.h"
namespace art {
@@ -84,41 +85,6 @@ int32_t ComputeUtf16Hash(const uint16_t* chars, size_t char_count) {
return hash;
}
-
-uint16_t GetUtf16FromUtf8(const char** utf8_data_in) {
- uint8_t one = *(*utf8_data_in)++;
- if ((one & 0x80) == 0) {
- // one-byte encoding
- return one;
- }
- // two- or three-byte encoding
- uint8_t two = *(*utf8_data_in)++;
- if ((one & 0x20) == 0) {
- // two-byte encoding
- return ((one & 0x1f) << 6) | (two & 0x3f);
- }
- // three-byte encoding
- uint8_t three = *(*utf8_data_in)++;
- return ((one & 0x0f) << 12) | ((two & 0x3f) << 6) | (three & 0x3f);
-}
-
-int CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(const char* utf8_1, const char* utf8_2) {
- for (;;) {
- if (*utf8_1 == '\0') {
- return (*utf8_2 == '\0') ? 0 : -1;
- } else if (*utf8_2 == '\0') {
- return 1;
- }
-
- int c1 = GetUtf16FromUtf8(&utf8_1);
- int c2 = GetUtf16FromUtf8(&utf8_2);
-
- if (c1 != c2) {
- return c1 > c2 ? 1 : -1;
- }
- }
-}
-
int CompareModifiedUtf8ToUtf16AsCodePointValues(const char* utf8_1, const uint16_t* utf8_2) {
for (;;) {
if (*utf8_1 == '\0') {
diff --git a/runtime/utf.h b/runtime/utf.h
index 4c9a1d9..cc5e6d4 100644
--- a/runtime/utf.h
+++ b/runtime/utf.h
@@ -29,9 +29,10 @@
* See http://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8 for the details.
*/
namespace art {
+
namespace mirror {
-template<class T> class PrimitiveArray;
-typedef PrimitiveArray<uint16_t> CharArray;
+ template<class T> class PrimitiveArray;
+ typedef PrimitiveArray<uint16_t> CharArray;
} // namespace mirror
/*
diff --git a/runtime/utils.cc b/runtime/utils.cc
index dcfe8a7..28ee58c 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -34,7 +34,7 @@
#include "mirror/string.h"
#include "object_utils.h"
#include "os.h"
-#include "utf.h"
+#include "utf-inl.h"
#if !defined(HAVE_POSIX_CLOCKS)
#include <sys/time.h>