Reviewed By: mbouaziz Differential Revision: D9028059 fbshipit-source-id: a82664103master
parent
4cc8563212
commit
396caca5d6
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
package codetoanalyze.java.performance;
|
||||
public class Array {
|
||||
|
||||
public void array_access_good() {
|
||||
float[] radii = new float[8];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
radii[i * 2] = radii[i];
|
||||
radii[i * 2 + 1] = radii[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void array_access_overrun_bad() {
|
||||
float[] radii = new float[8];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
radii[i * 2] = radii[i];
|
||||
radii[i * 2 + 2] = radii[i] + 1;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue