Bug 1081406: Remove unnecessary numeric casts. r=rnewman

This commit is contained in:
Chris Kitching 2014-10-11 00:42:36 +01:00
parent 822caf0082
commit 6d36f49b0b
17 changed files with 27 additions and 27 deletions

View File

@ -282,8 +282,8 @@ public class CrashReporter extends Activity
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);
}

View File

@ -1016,9 +1016,9 @@ public abstract class GeckoApp
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;

View File

@ -107,8 +107,8 @@ public class GeckoBatteryManager extends BroadcastReceiver {
}
// 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;

View File

@ -142,7 +142,7 @@ public class GeckoJavaSampler {
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);

View File

@ -61,7 +61,7 @@ public class PropertyAnimator implements Runnable {
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);

View File

@ -293,10 +293,10 @@ public class ICODecoder implements Iterable<Bitmap> {
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);

View File

@ -53,7 +53,7 @@ abstract class Axis {
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) {

View File

@ -124,7 +124,7 @@ final class DisplayPortCalculator {
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 {
@ -746,7 +746,7 @@ final class DisplayPortCalculator {
@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

View File

@ -170,7 +170,7 @@ class JavaPanZoomController
@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);
}
}
@ -660,7 +660,7 @@ class JavaPanZoomController
}
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

View File

@ -61,7 +61,7 @@ public class LayerMarginsAnimator {
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

View File

@ -136,10 +136,10 @@ public class PluginLayer extends TileLayer {
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;
}
}

View File

@ -75,7 +75,7 @@ public class SharedPreferencesClientsDataDelegate implements ClientsDataDelegate
@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

View File

@ -200,7 +200,7 @@ public class Utils {
}
public static long decimalSecondsToMilliseconds(Integer decimal) {
return (long)(decimal * 1000);
return (decimal * 1000);
}
public static byte[] sha256(byte[] in)

View File

@ -56,7 +56,7 @@ public class HKDF {
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);

View File

@ -198,7 +198,7 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter implements BaseGlob
}
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);
}
}

View File

@ -76,11 +76,11 @@ class MotionEventReplayer {
}
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)

View File

@ -87,7 +87,7 @@ public class FadedTextView extends ThemedTextView {
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;