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

Commit f8a4152c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Extract four byte sequence modified UTF-8 into separate classes."

parents e363a3fe b90e6818
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -68,7 +68,7 @@ public class FastDataPerfTest {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
        while (state.keepRunning()) {
            os.reset();
            os.reset();
            final FastDataOutput out = FastDataOutput.obtainUsing4ByteSequences(os);
            final FastDataOutput out = ArtFastDataOutput.obtain(os);
            try {
            try {
                doWrite(out);
                doWrite(out);
                out.flush();
                out.flush();
@@ -84,7 +84,7 @@ public class FastDataPerfTest {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
        while (state.keepRunning()) {
            os.reset();
            os.reset();
            final FastDataOutput out = FastDataOutput.obtainUsing3ByteSequences(os);
            final FastDataOutput out = FastDataOutput.obtain(os);
            try {
            try {
                doWrite(out);
                doWrite(out);
                out.flush();
                out.flush();
@@ -116,7 +116,7 @@ public class FastDataPerfTest {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
        while (state.keepRunning()) {
            is.reset();
            is.reset();
            final FastDataInput in = FastDataInput.obtainUsing4ByteSequences(is);
            final FastDataInput in = ArtFastDataInput.obtain(is);
            try {
            try {
                doRead(in);
                doRead(in);
            } finally {
            } finally {
@@ -131,7 +131,7 @@ public class FastDataPerfTest {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
        while (state.keepRunning()) {
            is.reset();
            is.reset();
            final FastDataInput in = FastDataInput.obtainUsing3ByteSequences(is);
            final FastDataInput in = FastDataInput.obtain(is);
            try {
            try {
                doRead(in);
                doRead(in);
            } finally {
            } finally {
+2 −2
Original line number Original line Diff line number Diff line
@@ -37,7 +37,7 @@ import android.os.Environment;
import android.util.AtomicFile;
import android.util.AtomicFile;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.FastDataInput;
import com.android.internal.util.ArtFastDataInput;


import libcore.io.IoUtils;
import libcore.io.IoUtils;


@@ -254,7 +254,7 @@ public class NetworkStatsDataMigrationUtils {
    private static void readPlatformCollection(@NonNull NetworkStatsCollection.Builder builder,
    private static void readPlatformCollection(@NonNull NetworkStatsCollection.Builder builder,
            @NonNull File file) throws IOException {
            @NonNull File file) throws IOException {
        final FileInputStream is = new FileInputStream(file);
        final FileInputStream is = new FileInputStream(file);
        final FastDataInput dataIn = new FastDataInput(is, BUFFER_SIZE);
        final ArtFastDataInput dataIn = new ArtFastDataInput(is, BUFFER_SIZE);
        try {
        try {
            readPlatformCollection(builder, dataIn);
            readPlatformCollection(builder, dataIn);
        } finally {
        } finally {
+4 −3
Original line number Original line Diff line number Diff line
@@ -22,7 +22,8 @@ import android.os.SystemProperties;
import android.system.ErrnoException;
import android.system.ErrnoException;
import android.system.Os;
import android.system.Os;


import com.android.internal.util.BinaryXmlPullParser;
import com.android.internal.util.ArtBinaryXmlPullParser;
import com.android.internal.util.ArtBinaryXmlSerializer;
import com.android.internal.util.BinaryXmlSerializer;
import com.android.internal.util.BinaryXmlSerializer;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.XmlUtils;
@@ -146,7 +147,7 @@ public class Xml {
     * @hide
     * @hide
     */
     */
    public static @NonNull TypedXmlPullParser newBinaryPullParser() {
    public static @NonNull TypedXmlPullParser newBinaryPullParser() {
        return new BinaryXmlPullParser();
        return new ArtBinaryXmlPullParser();
    }
    }


    /**
    /**
@@ -225,7 +226,7 @@ public class Xml {
     * @hide
     * @hide
     */
     */
    public static @NonNull TypedXmlSerializer newBinarySerializer() {
    public static @NonNull TypedXmlSerializer newBinarySerializer() {
        return new BinaryXmlSerializer();
        return new ArtBinaryXmlSerializer();
    }
    }


    /**
    /**
+36 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 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.
 */

package com.android.internal.util;

import android.annotation.NonNull;

import java.io.DataInput;
import java.io.InputStream;

/**
 * {@inheritDoc}
 * <p>
 * This decodes large code-points using 4-byte sequences, and <em>is not</em> compatible with the
 * {@link DataInput} API contract, which specifies that large code-points must be encoded with
 * 3-byte sequences.
 */
public class ArtBinaryXmlPullParser extends BinaryXmlPullParser {
    @NonNull
    protected FastDataInput obtainFastDataInput(@NonNull InputStream is) {
        return ArtFastDataInput.obtain(is);
    }
}
+37 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 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.
 */

package com.android.internal.util;

import android.annotation.NonNull;

import java.io.DataOutput;
import java.io.OutputStream;

/**
 * {@inheritDoc}
 * <p>
 * This encodes large code-points using 4-byte sequences and <em>is not</em> compatible with the
 * {@link DataOutput} API contract, which specifies that large code-points must be encoded with
 * 3-byte sequences.
 */
public class ArtBinaryXmlSerializer extends BinaryXmlSerializer {
    @NonNull
    @Override
    protected FastDataOutput obtainFastDataOutput(@NonNull OutputStream os) {
        return ArtFastDataOutput.obtain(os);
    }
}
Loading