private void branchIfDirty ( CodeBuilder b , boolean includePk , Label label ) { int count = mAllProperties . size ( ) ; int ordinal = 0 ; int andMask = 0 ; boolean anyNonDerived = false ; for ( StorableProperty property : mAllProperties . values ( ) ) { if ( ! property . isDerived ( ) ) { anyNonDerived = true ; if ( ! property . isJoin ( ) && ( ! property . isPrimaryKeyMember ( ) || includePk ) ) { // Logical 'and' will convert state 1 (clean) to state 0, so // that it will be ignored. State 3 (dirty) is what we're // looking for, and it turns into 2. Essentially, we leave the // high order bit on, since there is no state which has the // high order bit on unless the low order bit is also on. andMask |= 2 << ( ( ordinal & 0xf ) * 2 ) ; } } ordinal ++ ; if ( ( ordinal & 0xf ) == 0 || ordinal >= count ) { if ( anyNonDerived ) { String stateFieldName = PROPERTY_STATE_FIELD_NAME + ( ( ordinal - 1 ) >> 4 ) ; b . loadThis ( ) ; b . loadField ( stateFieldName , TypeDesc . INT ) ; b . loadConstant ( andMask ) ; b . math ( Opcode . IAND ) ; // At least one property is dirty, so short circuit. b . ifZeroComparisonBranch ( label , "!=" ) ; } andMask = 0 ; anyNonDerived = false ; } } }
Generates code that branches to the given label if any properties are dirty .