AAPT2: Fixup namespace implementation

A few pieces were missing in the namespace mangling implementation.
Namespace aware libraries now work, along with R class generation.

Bug: 64706588
Test: make AaptTestNamespace_App
Change-Id: I12f78d6aa909e782c0faf7ceaa36058f2e6c864a
diff --git a/tools/aapt2/NameMangler.h b/tools/aapt2/NameMangler.h
index 1305a4c..f1aad29 100644
--- a/tools/aapt2/NameMangler.h
+++ b/tools/aapt2/NameMangler.h
@@ -69,8 +69,7 @@
    * The mangled name should contain symbols that are illegal to define in XML,
    * so that there will never be name mangling collisions.
    */
-  static std::string MangleEntry(const std::string& package,
-                                 const std::string& name) {
+  static std::string MangleEntry(const std::string& package, const std::string& name) {
     return package + "$" + name;
   }
 
@@ -86,8 +85,8 @@
     }
 
     out_package->assign(out_name->data(), pivot);
-    out_name->assign(out_name->data() + pivot + 1,
-                     out_name->size() - (pivot + 1));
+    std::string new_name = out_name->substr(pivot + 1);
+    *out_name = std::move(new_name);
     return true;
   }