[is_valid] Add optimization and suppress warnings.

Replace boost::size(...) > 0 with !boost::empty(...).
Suppress unused parameter and constant conditional expression msvc
warnings.
This commit is contained in:
Adam Wulkiewicz
2015-06-12 16:37:58 +02:00
parent 6e88772e27
commit 843ef4eac8
7 changed files with 38 additions and 7 deletions

View File

@@ -3,6 +3,7 @@
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -12,6 +13,8 @@
#include <cstddef>
#include <boost/core/ignore_unused.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
@@ -57,6 +60,8 @@ struct has_valid_corners<Box, 0>
template <typename VisitPolicy>
static inline bool apply(Box const&, VisitPolicy& visitor)
{
boost::ignore_unused(visitor);
return visitor.template apply<no_failure>();
}
};

View File

@@ -3,6 +3,7 @@
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -18,6 +19,7 @@
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/util/condition.hpp>
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/algorithms/equals.hpp>
@@ -138,7 +140,8 @@ public:
static inline bool apply(MultiLinestring const& multilinestring,
VisitPolicy& visitor)
{
if (AllowEmptyMultiGeometries && boost::empty(multilinestring))
if (BOOST_GEOMETRY_CONDITION(
AllowEmptyMultiGeometries && boost::empty(multilinestring)))
{
return visitor.template apply<no_failure>();
}

View File

@@ -3,6 +3,7 @@
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -22,6 +23,7 @@
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/util/condition.hpp>
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/geometries/box.hpp>
@@ -253,7 +255,8 @@ public:
{
typedef debug_validity_phase<MultiPolygon> debug_phase;
if (AllowEmptyMultiGeometries && boost::empty(multipolygon))
if (BOOST_GEOMETRY_CONDITION(
AllowEmptyMultiGeometries && boost::empty(multipolygon)))
{
return visitor.template apply<no_failure>();
}

View File

@@ -3,6 +3,7 @@
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -10,6 +11,7 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_POINTLIKE_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_POINTLIKE_HPP
#include <boost/core/ignore_unused.hpp>
#include <boost/range.hpp>
#include <boost/geometry/core/tags.hpp>
@@ -17,6 +19,8 @@
#include <boost/geometry/algorithms/validity_failure_type.hpp>
#include <boost/geometry/algorithms/dispatch/is_valid.hpp>
#include <boost/geometry/util/condition.hpp>
namespace boost { namespace geometry
{
@@ -34,6 +38,7 @@ struct is_valid<Point, point_tag>
template <typename VisitPolicy>
static inline bool apply(Point const&, VisitPolicy& visitor)
{
boost::ignore_unused(visitor);
return visitor.template apply<no_failure>();
}
};
@@ -51,7 +56,10 @@ struct is_valid<MultiPoint, multi_point_tag, AllowEmptyMultiGeometries>
static inline bool apply(MultiPoint const& multipoint,
VisitPolicy& visitor)
{
if (AllowEmptyMultiGeometries || boost::size(multipoint) > 0)
boost::ignore_unused(multipoint, visitor);
if (BOOST_GEOMETRY_CONDITION(
AllowEmptyMultiGeometries || !boost::empty(multipoint)))
{
// we allow empty multi-geometries, so an empty multipoint
// is considered valid

View File

@@ -3,6 +3,7 @@
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -55,6 +56,8 @@ struct is_topologically_closed
template <typename VisitPolicy>
static inline bool apply(Ring const&, VisitPolicy& visitor)
{
boost::ignore_unused(visitor);
return visitor.template apply<no_failure>();
}
};

View File

@@ -3,6 +3,7 @@
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -10,6 +11,8 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_SEGMENT_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_SEGMENT_HPP
#include <boost/core/ignore_unused.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tags.hpp>
@@ -44,6 +47,8 @@ struct is_valid<Segment, segment_tag>
template <typename VisitPolicy>
static inline bool apply(Segment const& segment, VisitPolicy& visitor)
{
boost::ignore_unused(visitor);
typename point_type<Segment>::type p[2];
detail::assign_point_from_index<0>(segment, p[0]);
detail::assign_point_from_index<1>(segment, p[1]);

View File

@@ -3,6 +3,7 @@
// Copyright (c) 2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -13,6 +14,7 @@
#include <sstream>
#include <boost/geometry/io/dsv/write.hpp>
#include <boost/geometry/util/condition.hpp>
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/algorithms/validity_failure_type.hpp>
#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
@@ -65,7 +67,8 @@ private:
static inline
validity_failure_type transform_failure_type(validity_failure_type failure)
{
if (AllowDuplicates && failure == failure_duplicate_points)
if (BOOST_GEOMETRY_CONDITION(
AllowDuplicates && failure == failure_duplicate_points))
{
return no_failure;
}
@@ -76,7 +79,8 @@ private:
validity_failure_type transform_failure_type(validity_failure_type failure,
bool is_linear)
{
if (is_linear && AllowSpikes && failure == failure_spikes)
if (BOOST_GEOMETRY_CONDITION(
is_linear && AllowSpikes && failure == failure_spikes))
{
return no_failure;
}
@@ -117,7 +121,7 @@ private:
bool is_linear,
SpikePoint const& spike_point)
{
if (is_linear && AllowSpikes)
if (BOOST_GEOMETRY_CONDITION(is_linear && AllowSpikes))
{
return;
}
@@ -167,7 +171,7 @@ private:
static inline void apply(std::ostringstream& oss,
Point const& point)
{
if (AllowDuplicates)
if (BOOST_GEOMETRY_CONDITION(AllowDuplicates))
{
return;
}