create read-only views more lazily
Submitted by Simon McVittie
Assigned to fol..@..e.bugs
Link to original bug (#697381)
Description
Folks has a lot of this pattern:
private Thing _thing = new Thing ();
private Thing _thing_ro = _thing.read_only_view;
public Thing thing
{
get { return this._thing_ro; }
set { this._thing = value; this._thing_ro = value.read_only_view; }
}
Replacing this with
private Thing _thing = new Thing ();
private Thing? _thing_ro = null;
public Thing thing
{
get
{
if (this._thing_ro == null)
this._thing_ro = this._thing.read_only_view;
return (!) this._thing_ro;
}
set { this._thing = value; this._thing_ro = null; }
}
might well save a few percent on startup performance benchmarks.
Version: git master