Avoid some string allocations.

Also avoid building a string one character at a time.

Change-Id: I3db26226c620a730b95637d5bfc23e2d4715cfb9
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 0ddcdf3..a7575ce 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -555,22 +555,19 @@
   size_t end = signature.size();
   bool process_return = false;
   while (offset < end) {
+    size_t start_offset = offset;
     char c = signature[offset];
     offset++;
     if (c == ')') {
       process_return = true;
       continue;
     }
-    // TODO: avoid building a string.
-    std::string descriptor;
-    descriptor += c;
     while (c == '[') {  // process array prefix
       if (offset >= end) {  // expect some descriptor following [
         return false;
       }
       c = signature[offset];
       offset++;
-      descriptor += c;
     }
     if (c == 'L') {  // process type descriptors
       do {
@@ -579,9 +576,10 @@
         }
         c = signature[offset];
         offset++;
-        descriptor += c;
       } while (c != ';');
     }
+    // TODO: avoid creating a std::string just to get a 0-terminated char array
+    std::string descriptor(signature.data() + start_offset, offset - start_offset);
     const DexFile::StringId* string_id = FindStringId(descriptor.c_str());
     if (string_id == NULL) {
       return false;