Derby
  1. Derby
  2. DERBY-5077

[patch] remove non productive instanceof checks

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.9.1.0
    • Component/s: SQL, Store
    • Labels:
      None
    • Urgency:
      Low

      Description

      various places in code does instanceof checks where the outcome can be determined statically to be always true or always false.

      removed these checks as they do nothing.

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        [bulk update] Close all resolved issues that haven't been updated for more than one year.

        Show
        Knut Anders Hatlen added a comment - [bulk update] Close all resolved issues that haven't been updated for more than one year.
        Hide
        Kristian Waagan added a comment -

        Committed to trunk with revision 1145926.

        Show
        Kristian Waagan added a comment - Committed to trunk with revision 1145926.
        Hide
        Kristian Waagan added a comment -

        Attaching patch 1a, which is the original patch with some additional changes:
        o removed one more instanceof in SubqueryNode
        o made checkColumnOrdering in MergeSort private and rewrote the comment. Still not sure if checking if the column is null adds value, but keeping it is no big deal (the method is only called from a sanity block)
        o merged two SanityManager.DEBUG blocks.

        Running the tests, will commit if they pass.

        Show
        Kristian Waagan added a comment - Attaching patch 1a, which is the original patch with some additional changes: o removed one more instanceof in SubqueryNode o made checkColumnOrdering in MergeSort private and rewrote the comment. Still not sure if checking if the column is null adds value, but keeping it is no big deal (the method is only called from a sanity block) o merged two SanityManager.DEBUG blocks. Running the tests, will commit if they pass.
        Hide
        Dave Brosius added a comment -

        determined the places where instanceof checks might detect null values, and replace with null checking. The rest of the places the instanceof was removed.

        Show
        Dave Brosius added a comment - determined the places where instanceof checks might detect null values, and replace with null checking. The rest of the places the instanceof was removed.
        Hide
        Dave Brosius added a comment -

        good point, i'll take a look and resubmit

        Show
        Dave Brosius added a comment - good point, i'll take a look and resubmit
        Hide
        Knut Anders Hatlen added a comment -

        Note that instanceof checks return false if the object is null, even if the statically known type matches the type in the check. So unless we know that the object is non-null, simply removing the check isn't safe. I haven't checked if that's a problem in the code that's touched by the patch, but thought I'd raise the issue.

        Show
        Knut Anders Hatlen added a comment - Note that instanceof checks return false if the object is null, even if the statically known type matches the type in the check. So unless we know that the object is non-null, simply removing the check isn't safe. I haven't checked if that's a problem in the code that's touched by the patch, but thought I'd raise the issue.

          People

          • Assignee:
            Kristian Waagan
            Reporter:
            Dave Brosius
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1h
              1h
              Remaining:
              Remaining Estimate - 1h
              1h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development