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

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

Merge "Replace possibly-expensive size() == 0 with isEmpty()"

parents e784f7a0 c74ee2f8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ public class ClipboardManager extends android.text.ClipboardManager {

    public void addPrimaryClipChangedListener(OnPrimaryClipChangedListener what) {
        synchronized (mPrimaryClipChangedListeners) {
            if (mPrimaryClipChangedListeners.size() == 0) {
            if (mPrimaryClipChangedListeners.isEmpty()) {
                try {
                    mService.addPrimaryClipChangedListener(
                            mPrimaryClipChangedServiceListener, mContext.getOpPackageName());
@@ -165,7 +165,7 @@ public class ClipboardManager extends android.text.ClipboardManager {
    public void removePrimaryClipChangedListener(OnPrimaryClipChangedListener what) {
        synchronized (mPrimaryClipChangedListeners) {
            mPrimaryClipChangedListeners.remove(what);
            if (mPrimaryClipChangedListeners.size() == 0) {
            if (mPrimaryClipChangedListeners.isEmpty()) {
                try {
                    mService.removePrimaryClipChangedListener(
                            mPrimaryClipChangedServiceListener);
+4 −4
Original line number Diff line number Diff line
@@ -508,14 +508,14 @@ public class ContentProviderOperation implements Parcelable {
        /** Create a ContentProviderOperation from this {@link Builder}. */
        public ContentProviderOperation build() {
            if (mType == TYPE_UPDATE) {
                if ((mValues == null || mValues.size() == 0)
                        && (mValuesBackReferences == null || mValuesBackReferences.size() == 0)) {
                if ((mValues == null || mValues.isEmpty())
                      && (mValuesBackReferences == null || mValuesBackReferences.isEmpty())) {
                    throw new IllegalArgumentException("Empty values");
                }
            }
            if (mType == TYPE_ASSERT) {
                if ((mValues == null || mValues.size() == 0)
                        && (mValuesBackReferences == null || mValuesBackReferences.size() == 0)
                if ((mValues == null || mValues.isEmpty())
                      && (mValuesBackReferences == null || mValuesBackReferences.isEmpty())
                        && (mExpectedCount == null)) {
                    throw new IllegalArgumentException("Empty values");
                }
+11 −0
Original line number Diff line number Diff line
@@ -203,6 +203,17 @@ public final class ContentValues implements Parcelable {
        return mValues.size();
    }

    /**
     * Indicates whether this collection is empty.
     *
     * @return true iff size == 0
     * {@hide}
     * TODO: consider exposing this new method publicly
     */
    public boolean isEmpty() {
        return mValues.isEmpty();
    }

    /**
     * Remove a single value.
     *
+2 −2
Original line number Diff line number Diff line
@@ -1449,7 +1449,7 @@ public final class SQLiteDatabase extends SQLiteClosable {
            sql.append('(');

            Object[] bindArgs = null;
            int size = (initialValues != null && initialValues.size() > 0)
            int size = (initialValues != null && !initialValues.isEmpty())
                    ? initialValues.size() : 0;
            if (size > 0) {
                bindArgs = new Object[size];
@@ -1541,7 +1541,7 @@ public final class SQLiteDatabase extends SQLiteClosable {
     */
    public int updateWithOnConflict(String table, ContentValues values,
            String whereClause, String[] whereArgs, int conflictAlgorithm) {
        if (values == null || values.size() == 0) {
        if (values == null || values.isEmpty()) {
            throw new IllegalArgumentException("Empty values");
        }

+4 −0
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@ To run tests in debug mode:

    -e debug true

To uninstall the package:

  adb shell pm uninstall -k com.android.frameworks.coretests

For more arguments, see the guide to command=line testing:

  https://developer.android.com/studio/test/command-line.html
Loading