Bug 1081406: Remove unnecessary numeric casts. r=rnewman
authorChris Kitching <chriskitching@linux.com>
Sat, 11 Oct 2014 00:42:36 +0100
changeset 209931 2878bf6cbc1f03db66ca60d665cd4a8667ffdfd9
parent 209930 adc99de50f0dc1461b1f80cc1b55be9df3123411
child 209932 b6dc73e98dc2ba01c68425528f1c8a8a220a5076
child 209982 4cf592b066efc4a56977a181d6aa4d81f78d3155
push id27630
push userryanvm@gmail.com
push dateSat, 11 Oct 2014 20:02:01 +0000
treeherdermozilla-central@b6dc73e98dc2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1081406
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1081406: Remove unnecessary numeric casts. r=rnewman
mobile/android/base/CrashReporter.java
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoBatteryManager.java
mobile/android/base/GeckoJavaSampler.java
mobile/android/base/animation/PropertyAnimator.java
mobile/android/base/favicons/decoders/ICODecoder.java
mobile/android/base/gfx/Axis.java
mobile/android/base/gfx/DisplayPortCalculator.java
mobile/android/base/gfx/JavaPanZoomController.java
mobile/android/base/gfx/LayerMarginsAnimator.java
mobile/android/base/gfx/PluginLayer.java
mobile/android/base/sync/SharedPreferencesClientsDataDelegate.java
mobile/android/base/sync/Utils.java
mobile/android/base/sync/crypto/HKDF.java
mobile/android/base/sync/syncadapter/SyncAdapter.java
mobile/android/base/tests/MotionEventReplayer.java
mobile/android/base/widget/FadedTextView.java
--- a/mobile/android/base/CrashReporter.java
+++ b/mobile/android/base/CrashReporter.java
@@ -277,18 +277,18 @@ public class CrashReporter extends Activ
             }
         }
         reader.close();
         return true;
     }
 
     private String generateBoundary() {
         // Generate some random numbers to fill out the boundary
-        int r0 = (int)((double)Integer.MAX_VALUE * Math.random());
-        int r1 = (int)((double)Integer.MAX_VALUE * Math.random());
+        int r0 = (int)(Integer.MAX_VALUE * Math.random());
+        int r1 = (int)(Integer.MAX_VALUE * Math.random());
         return String.format("---------------------------%08X%08X", r0, r1);
     }
 
     private void sendPart(OutputStream os, String boundary, String name, String data) {
         try {
             os.write(("--" + boundary + "\r\n" +
                       "Content-Disposition: form-data; name=\"" + name + "\"\r\n" +
                       "\r\n" +
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1011,19 +1011,19 @@ public abstract class GeckoApp
     }
 
     private int getBitmapSampleSize(BitmapFactory.Options options, int idealWidth, int idealHeight) {
         int width = options.outWidth;
         int height = options.outHeight;
         int inSampleSize = 1;
         if (height > idealHeight || width > idealWidth) {
             if (width > height) {
-                inSampleSize = Math.round((float)height / (float)idealHeight);
+                inSampleSize = Math.round((float)height / idealHeight);
             } else {
-                inSampleSize = Math.round((float)width / (float)idealWidth);
+                inSampleSize = Math.round((float)width / idealWidth);
             }
         }
         return inSampleSize;
     }
 
     private void hidePluginLayer(Layer layer) {
         LayerView layerView = mLayerView;
         layerView.removeLayer(layer);
--- a/mobile/android/base/GeckoBatteryManager.java
+++ b/mobile/android/base/GeckoBatteryManager.java
@@ -102,18 +102,18 @@ public class GeckoBatteryManager extends
             if (sCharging != previousCharging) {
                 sRemainingTime = kUnknownRemainingTime;
                 // The new remaining time is going to take some time to show up but
                 // it's the best way to show a not too wrong value.
                 sLastLevelChange = 0;
             }
 
             // We need two doubles because sLevel is a double.
-            double current =  (double)intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
-            double max = (double)intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
+            double current = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
+            double max = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
             if (current == -1 || max == -1) {
                 Log.e(LOGTAG, "Failed to get battery level!");
                 sLevel = kDefaultLevel;
             } else {
                 sLevel = current / max;
             }
 
             if (sLevel == 1.0 && sCharging) {
--- a/mobile/android/base/GeckoJavaSampler.java
+++ b/mobile/android/base/GeckoJavaSampler.java
@@ -137,17 +137,17 @@ public class GeckoJavaSampler {
         return sSamplingRunnable.getSample(aThreadId, aSampleId);
     }
 
     @WrapElementForJNI(allowMultithread = true, stubName = "GetSampleTimeJavaProfiling")
     public synchronized static double getSampleTime(int aThreadId, int aSampleId) {
         Sample sample = getSample(aThreadId, aSampleId);
         if (sample != null) {
             if (sample.mJavaTime != 0) {
-                return (double)(sample.mJavaTime -
+                return (sample.mJavaTime -
                     SystemClock.elapsedRealtime()) + getProfilerTime();
             }
             System.out.println("Sample: " + sample.mTime);
             return sample.mTime;
         }
         return 0;
     }
 
--- a/mobile/android/base/animation/PropertyAnimator.java
+++ b/mobile/android/base/animation/PropertyAnimator.java
@@ -56,17 +56,17 @@ public class PropertyAnimator implements
     private boolean mUseHardwareLayer;
 
     public PropertyAnimator(long duration) {
         this(duration, new DecelerateInterpolator());
     }
 
     public PropertyAnimator(long duration, Interpolator interpolator) {
         mDuration = duration;
-        mDurationReciprocal = 1.0f / (float) mDuration;
+        mDurationReciprocal = 1.0f / mDuration;
         mInterpolator = interpolator;
         mElementsList = new ArrayList<ElementHolder>();
         mFramePoster = FramePoster.create(this);
         mUseHardwareLayer = true;
     }
 
     public void setUseHardwareLayer(boolean useHardwareLayer) {
         mUseHardwareLayer = useHardwareLayer;
--- a/mobile/android/base/favicons/decoders/ICODecoder.java
+++ b/mobile/android/base/favicons/decoders/ICODecoder.java
@@ -288,20 +288,20 @@ public class ICODecoder implements Itera
         // Copy the ICONDIRENTRY we need into the new buffer.
         System.arraycopy(decodand, offset + iconDirEntry.getOffset(), decodeTarget, ICO_HEADER_LENGTH_BYTES, ICO_ICONDIRENTRY_LENGTH_BYTES);
 
         // Copy the payload into the new buffer.
         final int singlePayloadOffset =  ICO_HEADER_LENGTH_BYTES + ICO_ICONDIRENTRY_LENGTH_BYTES;
         System.arraycopy(decodand, offset + iconDirEntry.payloadOffset, decodeTarget, singlePayloadOffset, iconDirEntry.payloadSize);
 
         // Update the offset field of the ICONDIRENTRY to make the new ICO valid.
-        decodeTarget[ICO_HEADER_LENGTH_BYTES + 12] = (byte) singlePayloadOffset;
-        decodeTarget[ICO_HEADER_LENGTH_BYTES + 13] = (byte) (singlePayloadOffset >>> 8);
-        decodeTarget[ICO_HEADER_LENGTH_BYTES + 14] = (byte) (singlePayloadOffset >>> 16);
-        decodeTarget[ICO_HEADER_LENGTH_BYTES + 15] = (byte) (singlePayloadOffset >>> 24);
+        decodeTarget[ICO_HEADER_LENGTH_BYTES + 12] = singlePayloadOffset;
+        decodeTarget[ICO_HEADER_LENGTH_BYTES + 13] = (singlePayloadOffset >>> 8);
+        decodeTarget[ICO_HEADER_LENGTH_BYTES + 14] = (singlePayloadOffset >>> 16);
+        decodeTarget[ICO_HEADER_LENGTH_BYTES + 15] = (singlePayloadOffset >>> 24);
 
         // Decode the newly-constructed singleton-ICO.
         return BitmapUtils.decodeByteArray(decodeTarget);
     }
 
     /**
      * Fetch an iterator over the images in this ICO, or null if this ICO seems to be invalid.
      *
--- a/mobile/android/base/gfx/Axis.java
+++ b/mobile/android/base/gfx/Axis.java
@@ -48,17 +48,17 @@ abstract class Axis {
     private static float SNAP_LIMIT;
 
     // The minimum amount of space that must be present for an axis to be considered scrollable,
     // in pixels.
     private static float MIN_SCROLLABLE_DISTANCE;
 
     private static float getFloatPref(Map<String, Integer> prefs, String prefName, int defaultValue) {
         Integer value = (prefs == null ? null : prefs.get(prefName));
-        return (float)(value == null || value < 0 ? defaultValue : value) / 1000f;
+        return (value == null || value < 0 ? defaultValue : value) / 1000f;
     }
 
     private static int getIntPref(Map<String, Integer> prefs, String prefName, int defaultValue) {
         Integer value = (prefs == null ? null : prefs.get(prefName));
         return (value == null || value < 0 ? defaultValue : value);
     }
 
     static void initPrefs() {
--- a/mobile/android/base/gfx/DisplayPortCalculator.java
+++ b/mobile/android/base/gfx/DisplayPortCalculator.java
@@ -119,17 +119,17 @@ final class DisplayPortCalculator {
                 return false;
         }
         Log.i(LOGTAG, "Set strategy " + sStrategy.toString());
         return true;
     }
 
     private static float getFloatPref(Map<String, Integer> prefs, String prefName, int defaultValue) {
         Integer value = (prefs == null ? null : prefs.get(prefName));
-        return (float)(value == null || value < 0 ? defaultValue : value) / 1000f;
+        return (value == null || value < 0 ? defaultValue : value) / 1000f;
     }
 
     private static abstract class DisplayPortStrategy {
         /** Calculates a displayport given a viewport and panning velocity. */
         public abstract DisplayPortMetrics calculate(ImmutableViewportMetrics metrics, PointF velocity);
         /** Returns true if a checkerboard is about to be visible and we should not throttle drawing. */
         public abstract boolean aboutToCheckerboard(ImmutableViewportMetrics metrics, PointF velocity, DisplayPortMetrics displayPort);
         /** Notify the strategy of a new recorded draw time. Return false to turn off draw time recording. */
@@ -741,17 +741,17 @@ final class DisplayPortCalculator {
 
             predictedViewport = clampToPageBounds(predictedViewport, metrics);
             return !displayPort.contains(predictedViewport);
         }
 
         @Override
         public boolean drawTimeUpdate(long millis, int pixels) {
             // calculate the number of frames it took to draw a viewport-sized area
-            float normalizedTime = (float)mPixelArea * (float)millis / (float)pixels;
+            float normalizedTime = (float)mPixelArea * millis / pixels;
             int normalizedFrames = (int)FloatMath.ceil(normalizedTime * 60f / 1000f);
             // broaden our range on how long it takes to draw if the draw falls outside
             // the range. this allows it to grow gradually. this heuristic may need to
             // be tweaked into more of a floating window average or something.
             if (normalizedFrames <= mMinFramesToDraw) {
                 mMinFramesToDraw--;
             } else if (normalizedFrames > mMaxFramesToDraw) {
                 mMaxFramesToDraw++;
--- a/mobile/android/base/gfx/JavaPanZoomController.java
+++ b/mobile/android/base/gfx/JavaPanZoomController.java
@@ -165,17 +165,17 @@ class JavaPanZoomController
                     } else {
                         mMode = AxisLockMode.STICKY;
                     }
                 }
             }
 
             @Override public void prefValue(String pref, int value) {
                 if (pref.equals("ui.scrolling.gamepad_dead_zone")) {
-                    GamepadUtils.overrideDeadZoneThreshold((float)value / 1000f);
+                    GamepadUtils.overrideDeadZoneThreshold(value / 1000f);
                 }
             }
 
             @Override public void prefValue(String pref, boolean value) {
                 if (pref.equals("ui.scrolling.negate_wheel_scrollY")) {
                     mNegateWheelScrollY = value;
                 }
             }
@@ -655,17 +655,17 @@ class JavaPanZoomController
 
     private float panDistance(MotionEvent move) {
         float dx = mX.panDistance(move.getX(0));
         float dy = mY.panDistance(move.getY(0));
         return FloatMath.sqrt(dx * dx + dy * dy);
     }
 
     private void track(float x, float y, long time) {
-        float timeDelta = (float)(time - mLastEventTime);
+        float timeDelta = (time - mLastEventTime);
         if (FloatUtils.fuzzyEquals(timeDelta, 0)) {
             // probably a duplicate event, ignore it. using a zero timeDelta will mess
             // up our velocity
             return;
         }
         mLastEventTime = time;
 
 
--- a/mobile/android/base/gfx/LayerMarginsAnimator.java
+++ b/mobile/android/base/gfx/LayerMarginsAnimator.java
@@ -56,17 +56,17 @@ public class LayerMarginsAnimator {
         mMaxMargins = new RectF();
         mInterpolator = new DecelerateInterpolator();
         mTouchTravelDistance = new PointF();
 
         // Listen to the dynamic toolbar pref
         mPrefObserverId = PrefsHelper.getPref(PREF_SHOW_MARGINS_THRESHOLD, new PrefsHelper.PrefHandlerBase() {
             @Override
             public void prefValue(String pref, int value) {
-                SHOW_MARGINS_THRESHOLD = (float)value / 100.0f;
+                SHOW_MARGINS_THRESHOLD = value / 100.0f;
             }
 
             @Override
             public boolean isObserver() {
                 return true;
             }
         });
     }
--- a/mobile/android/base/gfx/PluginLayer.java
+++ b/mobile/android/base/gfx/PluginLayer.java
@@ -131,20 +131,20 @@ public class PluginLayer extends TileLay
 
             mMaxDimension = maxDimension;
             reset(rect);
         }
 
         private void clampToMaxSize() {
             if (width > mMaxDimension || height > mMaxDimension) {
                 if (width > height) {
-                    height = Math.round(((float)height/(float)width) * mMaxDimension);
+                    height = Math.round(((float)height/ width) * mMaxDimension);
                     width = mMaxDimension;
                 } else {
-                    width = Math.round(((float)width/(float)height) * mMaxDimension);
+                    width = Math.round(((float)width/ height) * mMaxDimension);
                     height = mMaxDimension;
                 }
             }
         }
 
         public void reset(RectF rect) {
             mRect = rect;
         }
--- a/mobile/android/base/sync/SharedPreferencesClientsDataDelegate.java
+++ b/mobile/android/base/sync/SharedPreferencesClientsDataDelegate.java
@@ -70,17 +70,17 @@ public class SharedPreferencesClientsDat
       long now = System.currentTimeMillis();
       setClientName(clientName, now);
     }
     return clientName;
   }
 
   @Override
   public synchronized void setClientsCount(int clientsCount) {
-    sharedPreferences.edit().putLong(SyncConfiguration.PREF_NUM_CLIENTS, (long) clientsCount).commit();
+    sharedPreferences.edit().putLong(SyncConfiguration.PREF_NUM_CLIENTS, clientsCount).commit();
   }
 
   @Override
   public boolean isLocalGUID(String guid) {
     return getAccountGUID().equals(guid);
   }
 
   @Override
--- a/mobile/android/base/sync/Utils.java
+++ b/mobile/android/base/sync/Utils.java
@@ -195,17 +195,17 @@ public class Utils {
     return (long)(decimal * 1000);
   }
 
   public static long decimalSecondsToMilliseconds(Long decimal) {
     return decimal * 1000;
   }
 
   public static long decimalSecondsToMilliseconds(Integer decimal) {
-    return (long)(decimal * 1000);
+    return (decimal * 1000);
   }
 
   public static byte[] sha256(byte[] in)
       throws NoSuchAlgorithmException {
     MessageDigest sha1 = MessageDigest.getInstance("SHA-256");
     return sha1.digest(in);
   }
 
--- a/mobile/android/base/sync/crypto/HKDF.java
+++ b/mobile/android/base/sync/crypto/HKDF.java
@@ -51,17 +51,17 @@ public class HKDF {
    * Output: OKM (output keyring material).
    */
   public static byte[] hkdfExpand(byte[] prk, byte[] info, int len) throws NoSuchAlgorithmException, InvalidKeyException {
     Mac hmacHasher = makeHMACHasher(prk);
 
     byte[] T  = {};
     byte[] Tn = {};
 
-    int iterations = (int) Math.ceil(((double)len) / ((double)BLOCKSIZE));
+    int iterations = (int) Math.ceil(((double)len) / (BLOCKSIZE));
     for (int i = 0; i < iterations; i++) {
       Tn = digestBytes(Utils.concatAll(Tn, info, Utils.hex2Byte(Integer.toHexString(i + 1))),
                        hmacHasher);
       T = Utils.concatAll(T, Tn);
     }
 
     byte[] result = new byte[len];
     System.arraycopy(T, 0, result, 0, len);
--- a/mobile/android/base/sync/syncadapter/SyncAdapter.java
+++ b/mobile/android/base/sync/syncadapter/SyncAdapter.java
@@ -193,17 +193,17 @@ public class SyncAdapter extends Abstrac
    */
   @Override
   public void requestBackoff(final long backoff) {
     if (this.backoffHandler == null) {
       throw new IllegalStateException("No backoff handler: requesting backoff outside run()?");
     }
     if (backoff > 0) {
       // Fuzz the backoff time (up to 25% more) to prevent client lock-stepping; agrees with desktop.
-      final long fuzzedBackoff = backoff + Math.round((double) backoff * 0.25d * Math.random());
+      final long fuzzedBackoff = backoff + Math.round(backoff * 0.25d * Math.random());
       this.backoffHandler.extendEarliestNextRequest(System.currentTimeMillis() + fuzzedBackoff);
     }
   }
 
   @Override
   public boolean shouldBackOffStorage() {
     if (thisSyncIsForced) {
       /*
--- a/mobile/android/base/tests/MotionEventReplayer.java
+++ b/mobile/android/base/tests/MotionEventReplayer.java
@@ -71,21 +71,21 @@ class MotionEventReplayer {
         }
         if (value.startsWith("0x")) {
             return Integer.parseInt(value.substring(2), 16);
         }
         return Integer.parseInt(value);
     }
 
     private float scaleX(float value) {
-        return value * (float)mSurfaceWidth / (float)CAPTURE_WINDOW_WIDTH;
+        return value * mSurfaceWidth / CAPTURE_WINDOW_WIDTH;
     }
 
     private float scaleY(float value) {
-        return value * (float)mSurfaceHeight / (float)CAPTURE_WINDOW_HEIGHT;
+        return value * mSurfaceHeight / CAPTURE_WINDOW_HEIGHT;
     }
 
     public void replayEvents(InputStream eventDescriptions)
             throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
     {
         // As an example, a line in the input stream might look like:
         //
         // MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=424.41055, y[0]=825.2412,
--- a/mobile/android/base/widget/FadedTextView.java
+++ b/mobile/android/base/widget/FadedTextView.java
@@ -82,17 +82,17 @@ public class FadedTextView extends Theme
 
     private static class FadedTextGradient extends LinearGradient {
         private final int mWidth;
         private final int mColor;
 
         public FadedTextGradient(int width, int fadeWidth, int color) {
             super(0, 0, width, 0,
                   new int[] { color, color, 0x0 },
-                  new float[] { 0,  ((float) (width - fadeWidth) / (float) width), 1.0f },
+                  new float[] { 0,  ((float) (width - fadeWidth) / width), 1.0f },
                   Shader.TileMode.CLAMP);
 
             mWidth = width;
             mColor = color;
         }
 
         public int getWidth() {
             return mWidth;