The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix a point creation bug

These changes was commited to the Birdfont repository Thu, 15 Oct 2015 18:24:47 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Thu, 15 Oct 2015 18:24:47 +0000]

Updated Files

birdfont-test/TestRunner.vala
libbirdfont/Path.vala
--- a/birdfont-test/TestRunner.vala +++ b/birdfont-test/TestRunner.vala @@ -50,23 +50,27 @@ static void speed_test () { Test test_object = new Test.time ("GObject"); - for (uint i = 0; i < 3000 * 300; i++) { - GLib.Object o = new GLib.Object (); + for (uint i = 0; i < 3000; i++) { + for (uint j = 0; j < 300; j++) { + GLib.Object o = new GLib.Object (); + } } test_object.print (); Test test_ref = new Test.time ("GObject ref"); - for (uint i = 0; i < 3000 * 300; i++) { - GLib.Object o = new GLib.Object (); - - for (int j = 0; j < 7; j++) { - o.ref (); - } - - for (int j = 0; j < 7; j++) { - o.unref (); + for (uint i = 0; i < 3000; i++) { + for (uint k = 0; k < 300; k++) { + GLib.Object o = new GLib.Object (); + + for (int j = 0; j < 7; j++) { + o.ref (); + } + + for (int j = 0; j < 7; j++) { + o.unref (); + } } } @@ -74,16 +78,20 @@ Test test_edit_point = new Test.time ("EditPoint creation"); - for (uint i = 0; i < 3000 * 300; i++) { - EditPoint ep = new EditPoint (); + for (uint i = 0; i < 3000; i++) { + for (uint j = 0; j < 300; j++) { + EditPoint ep = new EditPoint (); + } } test_edit_point.print (); Test test_path = new Test.time ("Simple path creation"); - for (uint i = 0; i < 3000 * 300; i++) { - Path p = new Path (); + for (uint i = 0; i < 3000; i++) { + for (uint j = 0; j < 3000; j++) { + Path p = new Path (); + } } test_path.print ();
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -964,19 +964,17 @@ } public EditPoint add_point (EditPoint p) { - int prev_index; EditPoint previous_point; if (points.size == 0) { points.add (p); - p.prev = points.get (0).get_link_item (); - p.next = points.get (0).get_link_item (); + p.prev = p; + p.next = p; } else { previous_point = points.get (points.size - 1); points.add (p); - p.prev = (!) previous_point; - p.next = null; - points.add (p); + p.prev = previous_point; + p.next = previous_point.next; } last_point = p;