diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2020-04-20 21:29:15 -0600 |
|---|---|---|
| committer | Jeff Sharkey <jsharkey@google.com> | 2020-04-21 22:59:26 +0000 |
| commit | 0223df096ca4d25112e9b014a6591b982db4dfc1 (patch) | |
| tree | fcb6bc45208e315eefb108fa60cc5e0d03ce8e28 /core/java/android/content/Intent.java | |
| parent | d387e79ae1cbc6b4fd16bfc315ec2fc63f6f6aca (diff) | |
Update some Parcelables to send Strings UTF-8.
An earlier CL with benchmarks has shown that sending strings as UTF-8
is 50% faster for US-ASCII strings, and still 68% faster for complex
strings referencing higher Unicode planes. (So an improvement in
both cases!)
Since code across the OS still makes heavy assumptions about Parcel
strings typically being UTF-16, we need to carefully migrate
Parcelables by hand, which is what this CLs begins doing.
This is a purely mechanical refactoring with no functional changes.
Bug: 154436100
Test: manual
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: Ia9e581efd7c40269342b7528ca07363deb843c0f
Diffstat (limited to 'core/java/android/content/Intent.java')
| -rw-r--r-- | core/java/android/content/Intent.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index b1d6c830d3b7..def150ab49e5 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -888,8 +888,8 @@ public class Intent implements Parcelable, Cloneable { public ShortcutIconResource createFromParcel(Parcel source) { ShortcutIconResource icon = new ShortcutIconResource(); - icon.packageName = source.readString(); - icon.resourceName = source.readString(); + icon.packageName = source.readString8(); + icon.resourceName = source.readString8(); return icon; } @@ -906,8 +906,8 @@ public class Intent implements Parcelable, Cloneable { } public void writeToParcel(Parcel dest, int flags) { - dest.writeString(packageName); - dest.writeString(resourceName); + dest.writeString8(packageName); + dest.writeString8(resourceName); } @Override @@ -10807,12 +10807,12 @@ public class Intent implements Parcelable, Cloneable { } public void writeToParcel(Parcel out, int flags) { - out.writeString(mAction); + out.writeString8(mAction); Uri.writeToParcel(out, mData); - out.writeString(mType); - out.writeString(mIdentifier); + out.writeString8(mType); + out.writeString8(mIdentifier); out.writeInt(mFlags); - out.writeString(mPackage); + out.writeString8(mPackage); ComponentName.writeToParcel(mComponent, out); if (mSourceBounds != null) { @@ -10826,7 +10826,7 @@ public class Intent implements Parcelable, Cloneable { final int N = mCategories.size(); out.writeInt(N); for (int i=0; i<N; i++) { - out.writeString(mCategories.valueAt(i)); + out.writeString8(mCategories.valueAt(i)); } } else { out.writeInt(0); @@ -10865,12 +10865,12 @@ public class Intent implements Parcelable, Cloneable { } public void readFromParcel(Parcel in) { - setAction(in.readString()); + setAction(in.readString8()); mData = Uri.CREATOR.createFromParcel(in); - mType = in.readString(); - mIdentifier = in.readString(); + mType = in.readString8(); + mIdentifier = in.readString8(); mFlags = in.readInt(); - mPackage = in.readString(); + mPackage = in.readString8(); mComponent = ComponentName.readFromParcel(in); if (in.readInt() != 0) { @@ -10882,7 +10882,7 @@ public class Intent implements Parcelable, Cloneable { mCategories = new ArraySet<String>(); int i; for (i=0; i<N; i++) { - mCategories.add(in.readString().intern()); + mCategories.add(in.readString8().intern()); } } else { mCategories = null; |
