The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix a performance issue connected to multimasters

These changes was commited to the Birdfont repository Sun, 13 Dec 2015 11:36:41 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sun, 13 Dec 2015 11:36:41 +0000]

Updated Files

libbirdfont/GlyphCollection.vala
--- a/libbirdfont/GlyphCollection.vala +++ b/libbirdfont/GlyphCollection.vala @@ -68,8 +68,11 @@ i = glyph_masters.size - 1; } - return_val_if_fail (0 <= i < glyph_masters.size, new GlyphMaster ()); - + if (unlikely (!(0 <= i < glyph_masters.size))) { + warning(@"index out of bounds $i"); + return new GlyphMaster (); + } + return glyph_masters.get (i); } @@ -84,14 +87,20 @@ } public GlyphMaster get_master (string id) { + GlyphMaster? found = null; + foreach (GlyphMaster m in glyph_masters) { if (m.get_id () == id) { - return m; + found = m; } } - warning ("Master not found for id $(id)."); - return new GlyphMaster (); + if (unlikely (found == null)) { + warning ("Master not found for id $(id)."); + return new GlyphMaster (); + } + + return (!) found; } public bool is_multimaster() { @@ -121,7 +130,7 @@ public void set_selected_master (GlyphMaster m) { current_master = glyph_masters.index_of (m); - if (current_master == -1) { + if (unlikely (current_master == -1)) { warning ("Master does not exits"); current_master = 0; }