Simple optimisation for BufferChecks.checkBufferSize

Started by Matthias, May 19, 2006, 23:44:19

Previous topic - Next topic

Matthias

The method checkBufferSize() in org.lwjgl.BufferChecks builds a string for an exception. The code for this prevents this method from being inlined (becuase it is to large).

The exception throwing should be moved to another method:
private static void checkBufferSize(Buffer buf, int size) {
		if (buf.remaining() < size) {
			throwBufferSizeException(buf, size);
		}
	}

	private static void throwBufferSizeException(Buffer buf, int size) {
		throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size);
	}

this allows checkBufferSize to be inlined (even by the client compiler - verified with the fastdebug build b84 of the jdk1.6 VM).

indiana

It would be cool if that could be done, 'cause this method is called a bazillion times!  8)

elias


indiana

Thanks! 8)

Using the opportunity to hijack this thread... when do we see the 1.0 release?   :D

WiESi

Quote from: "indiana"Using the opportunity to hijack this thread... when do we see the 1.0 release?

Yeah, and when you aren't ready to release 1.0 soon, would a 0.100 release be possible?

Matzon

1.0 will be released RSN - I was waiting for elias to get back from a trip to SF, so that he could look over the patches and some other issues. Once these are resolved we should be good to go for 1.0 beta. Actual 1.0 release is pending someone to investigate input issues and some other issues.