Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8167425

Redundant code in method PerfLongVariant::sample

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 10
    • 7, 8, 9
    • hotspot
    • b21

        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();
        }

              shshahma Shafi Ahmad (Inactive)
              shshahma Shafi Ahmad (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: