What is the purpose of variable duplication in a method?
<p>I see this [below] all over in the Android code (and some other code sources). What is its point or purpose?</p>

<pre><code>class Foo {
    int mBar = 1337;

    static void main(String... args) {
        System.out.println(isFubar());
    }

    boolean isFubar() {
        int ret = mBar; // &lt;--- Focus of attention

        if (ret == 666)
            return true;
        else
            return false;
    }
}
</code></pre>

<p>It seems like a waste of time and resources. mBar clearly isn't being modified. There is no risk of it being modified (in the given context), so why would one duplicate the primitive just to preform a noninvasive check on it and return?</p>

<p>EDIT Specific example from the class CellLayout in the Android Source</p>

<pre><code>public void cellToRect(int cellX, int cellY, int cellHSpan, int cellVSpan, RectF dragRect) {
        final boolean portrait = mPortrait;    &lt;--- Here it is
        final int cellWidth = mCellWidth;
        final int cellHeight = mCellHeight;
        final int widthGap = mWidthGap;
        final int heightGap = mHeightGap;

        final int hStartPadding = portrait ? mShortAxisStartPadding : mLongAxisStartPadding;
        final int vStartPadding = portrait ? mLongAxisStartPadding : mShortAxisStartPadding;

        int width = cellHSpan * cellWidth + ((cellHSpan - 1) * widthGap);
        int height = cellVSpan * cellHeight + ((cellVSpan - 1) * heightGap);

        int x = hStartPadding + cellX * (cellWidth + widthGap);
        int y = vStartPadding + cellY * (cellHeight + heightGap);

        dragRect.set(x, y, x + width, y + height);
    }
</code></pre>
