Clone in a terminal:
Commit f7daf70
Johan Mattsson - 2015-10-15T18:24:47+00:00
f7daf707019426c022c0b5e68997dbb877c9c692johan.mattsson.m@gmail.com

Fix a point creation bug

Changed files (2)

Diff

diff --git a/birdfont-test/TestRunner.vala b/birdfont-test/TestRunner.valaindex 3dfd70a..9baa8bd 100644--- a/birdfont-test/TestRunner.vala+++ b/birdfont-test/TestRunner.vala@@ -50,23 +50,27 @@ public class TestRunner : NativeWindow, GLib.Object  { 	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 @@ public class TestRunner : NativeWindow, GLib.Object  { 		 		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 ();diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex b4dda39..2e58509 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -964,19 +964,17 @@ public class Path : GLib.Object { 	}  	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;

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112