Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f0c6a5d authored by h00013079's avatar h00013079
Browse files

Optimize string interning in ParsedComponentImpl serialization



Changed writeToParcel() to use sForInternedString.parcel() for "name" field serialization
and updated the constructor to use sForInternedString.unparcel() during deserialization.
This improves memory efficiency by leveraging string interning for the component name,
reducing redundant string allocations when parceling/undarceling component data.

Bug:395218509

Change-Id: I01a6b500dc57ea5481a1b94271dc81daa2a031ff
Signed-off-by: default avatar <huangdezhi@hihonor.com>
parent 9c3c7c14
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ public abstract class ParsedComponentImpl implements ParsedComponent, Parcelable

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.name);
        sForInternedString.parcel(this.name, dest, flags);
        dest.writeInt(this.getIcon());
        dest.writeInt(this.getLabelRes());
        dest.writeCharSequence(this.getNonLocalizedLabel());
@@ -175,7 +175,7 @@ public abstract class ParsedComponentImpl implements ParsedComponent, Parcelable
        // We use the boot classloader for all classes that we load.
        final ClassLoader boot = Object.class.getClassLoader();
        //noinspection ConstantConditions
        this.name = in.readString();
        this.name = sForInternedString.unparcel(in);
        this.icon = in.readInt();
        this.labelRes = in.readInt();
        this.nonLocalizedLabel = in.readCharSequence();