TickitPen should store a refcount

Registered by Paul "LeoNerd" Evans on 2015-03-05

Given as most TickitPen instances are not modified after construction, it makes sense to consider storing multiple references to the same instance instead of cloning it (especially in things like RenderBuffer which stores a pen per cell). This would reduce CPU and memory usage by a lot.

I suggest a behaviour similar to Perl SVs; that a new pen starts with refcount 1, gets destroyed when it hits 0, and has a pair of ref/unref functions:

  TickitPen *tickit_pen_ref(TickitPen *pen); // returns pen, for convenience
  void tickit_pen_unref(TickitPen *pen); // may destroy pen

It might also make sense to have an accessor to return the current refcount, or at least to check if the refcount is 1 - in that situation an in-place mutation may be allowable, whereas with refcount > 1 the user may wish to clone, unref the old one, then mutate the new copy.

Blueprint information

Status:
Complete
Approver:
None
Priority:
High
Drafter:
Paul "LeoNerd" Evans
Direction:
Approved
Assignee:
None
Definition:
Approved
Series goal:
None
Implementation:
Implemented
Milestone target:
None
Started by
Paul "LeoNerd" Evans on 2015-08-16
Completed by
Paul "LeoNerd" Evans on 2015-08-31

Related branches

Sprints

Whiteboard

Done as of -r368

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.