After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 697381 - create read-only views more lazily
create read-only views more lazily
Status: RESOLVED OBSOLETE
Product: folks
Classification: Platform
Component: general
git master
Other Linux
: Normal enhancement
: Unset
Assigned To: folks-maint
folks-maint
Depends on:
Blocks:
 
 
Reported: 2013-04-05 17:35 UTC by Simon McVittie
Modified: 2018-09-21 16:02 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Simon McVittie 2013-04-05 17:35:21 UTC
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.
Comment 1 Simon McVittie 2013-04-05 17:38:47 UTC
Conversely, if we're creating read-only views of the same set repeatedly, giving the SmallSet a weak ref to the read-only view might be a win.

When testing SmallMap/SmallMultiMap, _read_only_view() (the implementation of read_only_view for SmallSet) was called 137000 times, accounting for 7.68% of cycle-estimation in callgrind.
Comment 2 GNOME Infrastructure Team 2018-09-21 16:02:10 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/folks/issues/61.