-
Enhancement
-
Resolution: Fixed
-
P4
-
7, 8, 9
-
b21
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8177321 | tbd | Unassigned | P4 | Closed | Not an Issue | |
JDK-8177322 | 8-pool | Fairoz Matte | P4 | Closed | Won't Fix |
215 void PerfLongVariant::sample() {
216
217 // JJJ - This should not happen. Maybe the first sample is taken
218 // while the _sample_helper is being null'ed out.
219 // assert(_sample_helper != NULL || _sampled != NULL, "unexpected state");
220 if (_sample_helper == NULL) return;
221
222 if (_sample_helper != NULL) {
223 *(jlong*)_valuep = _sample_helper->take_sample();
224 }
225 else if (_sampled != NULL) {
226 *(jlong*)_valuep = *_sampled;
227 }
228 }
The above function has redundant statement at line# 222, 224 and 225-227. Now a days compilers are smart enough to remove it but it is good practice not to have a redundant code. If it is really redundant code then above method can be re-written as:
void PerfLongVariant::sample() {
// JJJ - This should not happen. Maybe the first sample is taken
// while the _sample_helper is being null'ed out.
// assert(_sample_helper != NULL || _sampled != NULL, "unexpected state");
if (_sample_helper == NULL) return;
*(jlong*)_valuep = _sample_helper->take_sample();
}
216
217 // JJJ - This should not happen. Maybe the first sample is taken
218 // while the _sample_helper is being null'ed out.
219 // assert(_sample_helper != NULL || _sampled != NULL, "unexpected state");
220 if (_sample_helper == NULL) return;
221
222 if (_sample_helper != NULL) {
223 *(jlong*)_valuep = _sample_helper->take_sample();
224 }
225 else if (_sampled != NULL) {
226 *(jlong*)_valuep = *_sampled;
227 }
228 }
The above function has redundant statement at line# 222, 224 and 225-227. Now a days compilers are smart enough to remove it but it is good practice not to have a redundant code. If it is really redundant code then above method can be re-written as:
void PerfLongVariant::sample() {
// JJJ - This should not happen. Maybe the first sample is taken
// while the _sample_helper is being null'ed out.
// assert(_sample_helper != NULL || _sampled != NULL, "unexpected state");
if (_sample_helper == NULL) return;
*(jlong*)_valuep = _sample_helper->take_sample();
}
- backported by
-
JDK-8177321 Redundant code in method PerfLongVariant::sample
-
- Closed
-
-
JDK-8177322 Redundant code in method PerfLongVariant::sample
-
- Closed
-