comparison dwtx/draw2d/graph/Path.d @ 103:2d6540440fe6

Replace static ctors with lazy init.
author Frank Benoit <benoit@tionex.de>
date Sun, 03 Aug 2008 17:01:51 +0200
parents 95307ad235d9
children
comparison
equal deleted inserted replaced
102:0de61c6f08ca 103:2d6540440fe6
50 add(obj); 50 add(obj);
51 } 51 }
52 52
53 } 53 }
54 54
55 private static const Point CURRENT; 55 private static bool initStaticCtor_done = false;
56 private static Point CURRENT;
56 private static const double EPSILON = 1.04; 57 private static const double EPSILON = 1.04;
57 private static const Point NEXT; 58 private static Point NEXT;
58 private static const double OVAL_CONSTANT = 1.13; 59 private static const double OVAL_CONSTANT = 1.13;
59 60
60 static this(){ 61 private static void initStaticCtor(){
61 CURRENT = new Point(); 62 if( !initStaticCtor_done ){
62 NEXT = new Point(); 63 synchronized( Path.classinfo ){
64 if( !initStaticCtor_done ){
65 CURRENT = new Point();
66 NEXT = new Point();
67 initStaticCtor_done = true;
68 }
69 }
70 }
71 assert( CURRENT );
72 assert( NEXT );
63 } 73 }
64 74
65 /** 75 /**
66 * The bendpoint constraints. The path must go through these bendpoints. 76 * The bendpoint constraints. The path must go through these bendpoints.
67 */ 77 */
99 /** 109 /**
100 * Constructs a new path. 110 * Constructs a new path.
101 * @since 3.0 111 * @since 3.0
102 */ 112 */
103 public this() { 113 public this() {
114 initStaticCtor();
104 segments = new ArrayList(); 115 segments = new ArrayList();
105 grownSegments = new ArrayList(); 116 grownSegments = new ArrayList();
106 points = new PointList(); 117 points = new PointList();
107 visibleVertices = new HashSet(); 118 visibleVertices = new HashSet();
108 stack = new SegmentStack(); 119 stack = new SegmentStack();