27
27
#include < geos/noding/FastSegmentSetIntersectionFinder.h>
28
28
#include < geos/operation/distance/IndexedFacetDistance.h>
29
29
30
+ #include < mutex>
31
+
30
32
namespace geos {
31
33
namespace geom { // geos.geom
32
34
namespace prep { // geos.geom.prep
@@ -44,12 +46,12 @@ PreparedLineString::~PreparedLineString()
44
46
}
45
47
46
48
noding::FastSegmentSetIntersectionFinder*
47
- PreparedLineString::getIntersectionFinder ()
49
+ PreparedLineString::getIntersectionFinder () const
48
50
{
49
- if (! segIntFinder ) {
51
+ std::call_once (segIntFinderFlag, [ this ]( ) {
50
52
noding::SegmentStringUtil::extractSegmentStrings (&getGeometry (), segStrings);
51
- segIntFinder. reset ( new noding::FastSegmentSetIntersectionFinder (&segStrings) );
52
- }
53
+ segIntFinder = detail::make_unique< noding::FastSegmentSetIntersectionFinder> (&segStrings);
54
+ });
53
55
54
56
return segIntFinder.get ();
55
57
}
@@ -68,12 +70,12 @@ PreparedLineString::intersects(const geom::Geometry* g) const
68
70
69
71
/* public */
70
72
operation::distance::IndexedFacetDistance*
71
- PreparedLineString::
72
- getIndexedFacetDistance () const
73
+ PreparedLineString::getIndexedFacetDistance () const
73
74
{
74
- if (! indexedDistance ) {
75
- indexedDistance.reset (new operation::distance::IndexedFacetDistance (&getGeometry ()));
76
- }
75
+ std::call_once (indexedDistanceFlag, [this ]() {
76
+ indexedDistance = detail::make_unique<operation::distance::IndexedFacetDistance>(&getGeometry ());
77
+ });
78
+
77
79
return indexedDistance.get ();
78
80
}
79
81
0 commit comments