Nice/src/gnu/bytecode Field.java,1.6,1.7

Daniel Bonniot <[email protected]> Fri, 08 Apr 2005 13:31:11 +0000
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
Update of /cvsroot/nice/Nice/src/gnu/bytecode
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9950/src/gnu/bytecode

Modified Files:
	Field.java 
Log Message:
Don't write ConstantValue attributes for the default value, since that's
redundant.


Index: Field.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/gnu/bytecode/Field.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Field.java	31 Jul 2003 19:32:05 -0000	1.6
--- Field.java	8 Apr 2005 13:31:09 -0000	1.7
***************
*** 135,145 ****
        {
        case 'Z':
!         entry = cpool.addInt(((Boolean) value).booleanValue() ? 1 : 0); break;
        case 'C':
! 	entry = cpool.addInt(((Character) value).charValue());  break;
        case 'B':
        case 'S':
        case 'I':
! 	entry = cpool.addInt(((Number) value).intValue());  break;
        case 'J':
  	entry = cpool.addLong(((Number) value).longValue());  break;
--- 135,145 ----
        {
        case 'Z':
!         entry = addIfNotDefault(cpool, ((Boolean) value).booleanValue() ? 1 : 0); break;
        case 'C':
! 	entry = addIfNotDefault(cpool, ((Character) value).charValue());  break;
        case 'B':
        case 'S':
        case 'I':
! 	entry = addIfNotDefault(cpool, ((Number) value).intValue());  break;
        case 'J':
  	entry = cpool.addLong(((Number) value).longValue());  break;
***************
*** 151,156 ****
  	entry = cpool.addString(value.toString());  break;
        }
!     ConstantValueAttr attr = new ConstantValueAttr(entry.getIndex());
!     attr.addToFrontOf(this);
    }
  
--- 151,168 ----
  	entry = cpool.addString(value.toString());  break;
        }
!     if (entry != null)
!       {
!         ConstantValueAttr attr = new ConstantValueAttr(entry.getIndex());
!         attr.addToFrontOf(this);
!       }
!   }
! 
!   private CpoolEntry addIfNotDefault(ConstantPool cpool, int value)
!   {
!     if (value == 0)
!       // 0 is the default value, no need to specify it.
!       return null;
!     else
!       return cpool.addInt(value);
    }
  



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click