[geos-commits] [SCM] GEOS branch 3.12 updated. 548448f19b7afa188699cb555904b6789114b536
git at osgeo.org
git at osgeo.org
Thu Oct 24 13:40:12 PDT 2024
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".
The branch, 3.12 has been updated
via 548448f19b7afa188699cb555904b6789114b536 (commit)
from 1783c24ccc504ecbc5569e9283c901e77d969cca (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 548448f19b7afa188699cb555904b6789114b536
Author: Daniel Baston <dbaston at gmail.com>
Date: Wed Jun 19 16:33:56 2024 -0400
LineSegmentIndex: Avoid creating std::vector on heap
diff --git a/include/geos/simplify/LineSegmentIndex.h b/include/geos/simplify/LineSegmentIndex.h
index 136d7bedb..3a8de122d 100644
--- a/include/geos/simplify/LineSegmentIndex.h
+++ b/include/geos/simplify/LineSegmentIndex.h
@@ -60,7 +60,7 @@ public:
void remove(const geom::LineSegment* seg);
- std::unique_ptr< std::vector<geom::LineSegment*> >
+ std::vector<const geom::LineSegment*>
query(const geom::LineSegment* seg);
diff --git a/src/simplify/LineSegmentIndex.cpp b/src/simplify/LineSegmentIndex.cpp
index 42b99e18a..7de458c1f 100644
--- a/src/simplify/LineSegmentIndex.cpp
+++ b/src/simplify/LineSegmentIndex.cpp
@@ -54,15 +54,14 @@ private:
const LineSegment* querySeg;
- std::unique_ptr< std::vector<LineSegment*> > items;
+ std::vector<const LineSegment*> items;
public:
LineSegmentVisitor(const LineSegment* s)
:
ItemVisitor(),
- querySeg(s),
- items(new std::vector<LineSegment*>())
+ querySeg(s)
{}
~LineSegmentVisitor() override
@@ -70,43 +69,23 @@ public:
// nothing to do, LineSegments are not owned by us
}
- LineSegmentVisitor(const LineSegmentVisitor& o)
- :
- ItemVisitor(),
- querySeg(o.querySeg),
- items(new std::vector<LineSegment*>(*(o.items.get())))
- {
- }
-
- LineSegmentVisitor&
- operator=(const LineSegmentVisitor& o)
- {
- if(this == &o) {
- return *this;
- }
- querySeg = o.querySeg;
- items.reset(new std::vector<LineSegment*>(*(o.items.get())));
- return *this;
- }
-
void
visitItem(void* item) override
{
- LineSegment* seg = static_cast<LineSegment*>(item);
+ const LineSegment* seg = static_cast<const LineSegment*>(item);
if(Envelope::intersects(seg->p0, seg->p1,
querySeg->p0, querySeg->p1)) {
- items->push_back(seg);
+ items.push_back(seg);
}
}
- std::unique_ptr< std::vector<LineSegment*> >
+ std::vector<const LineSegment*>
getItems()
{
// NOTE: Apparently, this is 'source' method giving up the object resource.
return std::move(items);
}
-
};
@@ -144,7 +123,7 @@ LineSegmentIndex::remove(const LineSegment* seg)
}
/*public*/
-std::unique_ptr< std::vector<LineSegment*> >
+std::vector<const LineSegment*>
LineSegmentIndex::query(const LineSegment* querySeg)
{
Envelope env(querySeg->p0, querySeg->p1);
@@ -152,7 +131,7 @@ LineSegmentIndex::query(const LineSegment* querySeg)
LineSegmentVisitor visitor(querySeg);
index.query(&env, visitor);
- std::unique_ptr< std::vector<LineSegment*> > itemsFound = visitor.getItems();
+ auto itemsFound = visitor.getItems();
return itemsFound;
}
diff --git a/src/simplify/TaggedLineStringSimplifier.cpp b/src/simplify/TaggedLineStringSimplifier.cpp
index b9d1cccc8..04141bddb 100644
--- a/src/simplify/TaggedLineStringSimplifier.cpp
+++ b/src/simplify/TaggedLineStringSimplifier.cpp
@@ -267,7 +267,7 @@ TaggedLineStringSimplifier::hasOutputIntersection(
//std::unique_ptr<std::vector<LineSegment*>>
auto querySegs = outputIndex->query(&flatSeg);
- for(const LineSegment* querySeg : *querySegs) {
+ for(const LineSegment* querySeg : querySegs) {
if(hasInvalidIntersection(*querySeg, flatSeg)) {
return true;
}
@@ -304,7 +304,7 @@ TaggedLineStringSimplifier::hasInputIntersection(
{
const auto& querySegs = inputIndex->query(&flatSeg);
- for(const LineSegment* ls : *querySegs) {
+ for(const LineSegment* ls : querySegs) {
const TaggedLineSegment* querySeg = static_cast<const TaggedLineSegment*>(ls);
if (hasInvalidIntersection(*ls, flatSeg)) {
-----------------------------------------------------------------------
Summary of changes:
include/geos/simplify/LineSegmentIndex.h | 2 +-
src/simplify/LineSegmentIndex.cpp | 35 ++++++-----------------------
src/simplify/TaggedLineStringSimplifier.cpp | 4 ++--
3 files changed, 10 insertions(+), 31 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list