Null pointer check elimination

Per Bothner per@bothner.com
Sat Nov 12 21:26:00 GMT 2005


Chris Gray wrote:
> Another way to look at functions which return 'this' (and there are plenty of 
> those in the core Java libraries) is that
> sb = new StringBuffer(foo).append(foo).append(bar)
> is equivalent to
> sb = new StringBuffer(foo); sb.append(bar); sb.append(baz);
> in which it is quite obvious that sb never becomes null. So maybe just 
> special-casing 'return this' could yield optimisations without having to mess 
> with new type variants. etc..

That suggests a 'returns-this', which clearly is a function attribute,
as opposed to 'never-null', which is a type attribute.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/



More information about the Java mailing list