Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1054

Standardize "x = x op y" to "x op= y"

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2
    • 3.3
    • None
    • None

    Description

      Here's one of a series of proposed small simplification/optimizations across the code base. This can be rejected.

      The change is to standardize expressions like:

      x[i] = x[i] + b;

      to:

      x[i] += b;

      ... for any operation that has an 'op=' version. The resulting byte code is very marginally faster since the target is evaluated once; this might matter in a tight loop manipulating a 2D array cell.

      There's a minor argument that it is simpler code. Since both styles appear in the code now, this would also represent a tiny standardization.

      The counter-argument is that "x += foo" might risk being misread more readily as "x = foo"

      Attachments

        1. MATH-1054.patch
          50 kB
          Sean R. Owen

        Activity

          People

            Unassigned Unassigned
            srowen Sean R. Owen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: