On Dec 7, 2012, at 10:35 AM, Benjamin Kramer <[email protected]> wrote:

>> Two lookups would be noticeably slower.  I also suspect the memory overhead 
>> is inconsequential.  We are talking about a few kilobytes at most, on a very 
>> complicated file.  We can bit-mangle the pointer, if you like, to provide a 
>> sentinel value.
> 
> Maybe we should specialize Optional on types that have pointerLikeTypeTraits 
> and automatically enable bitmangling if it has a spare bit.

I had the same thought.  We'd need to be careful about alignment, but it seems 
completely doable.

> 
> OTOH Optional on pointers doesn't seem to be very common in clang so it may 
> not be worth the effort.

It might be more common if it was implemented more efficiently.  It's a nice 
type-safe abstraction in the places where it is useful.

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to