| CODENOTIFIER | HelpYou are not signed inSign in |
Project: JNA
Revision: 638
Author: twalljava
Date: 13 Aug 2008 09:51:59
Changes:avoid reallocating Integer objects
Files:| ... | ...@@ -46,6 +46,9 @@ | |
| 46 | 46 | /** First alternate convention (currently used only for w32 stdcall). */ |
| 47 | 47 | public static final int ALT_CONVENTION = 1; |
| 48 | 48 | |
| 49 | static final Integer INTEGER_TRUE = new Integer(-1); | |
| 50 | static final Integer INTEGER_FALSE = new Integer(0); | |
| 51 | ||
| 49 | 52 | /** |
| 50 | 53 | * Obtain a <code>Function</code> representing a native |
| 51 | 54 | * function that follows the standard "C" calling convention. |
| ... | ...@@ -415,7 +418,7 @@ | |
| 415 | 418 | // Default conversion of boolean to int; if you want something |
| 416 | 419 | // different, use a ToNativeConverter |
| 417 | 420 | else if (arg instanceof Boolean) { |
| 418 | return new Integer(Boolean.TRUE.equals(arg) ? -1 : 0); | |
| 421 | return Boolean.TRUE.equals(arg) ? INTEGER_TRUE : INTEGER_FALSE; | |
| 419 | 422 | } |
| 420 | 423 | else if (String[].class == argClass) { |
| 421 | 424 | return new StringArray((String[])arg); |
| ... | ...@@ -6,6 +6,7 @@ | |
| 6 | 6 | <li>Check for w32 libraries with a "lib" prefix in addition to normal lookup. |
| 7 | 7 | <li>Add Solaris8 compatibility to sunos-sparc build (Corey Puffalt). |
| 8 | 8 | <li>Look up libraries using web start library path, if appropriate (Corey Puffalt). |
| 9 | <li>Use constants to return integer boolean values. | |
| 9 | 10 | </ul> |
| 10 | 11 | <b>Bug Fixes</b><br> |
| 11 | 12 | <ul> |
| ... | ...@@ -347,7 +347,8 @@ | |
| 347 | 347 | return ((Structure)value).getPointer(); |
| 348 | 348 | } |
| 349 | 349 | else if (cls == boolean.class || cls == Boolean.class) { |
| 350 | return new Integer(Boolean.TRUE.equals(value)?-1:0); | |
| 350 | return Boolean.TRUE.equals(value) ? | |
| 351 | Function.INTEGER_TRUE : Function.INTEGER_FALSE; | |
| 351 | 352 | } |
| 352 | 353 | else if (cls == String.class || cls == WString.class) { |
| 353 | 354 | // Store in a weak hash map to delay GC until string |