Skip to content

Commit

Permalink
Remove a couple of boost methods (valhalla#1438)
Browse files Browse the repository at this point in the history
* Remove unused boost includes

* Add boost includes needed in this test.

* Remove boost hash - just hash the combined string.

* Update StartsWith and EndWith methods to replace use of boost with simple string methods.
  • Loading branch information
dnesbitt61 committed Jul 24, 2018
1 parent 3fa3af6 commit 47555cc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/baldr/streetname.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "baldr/streetname.h"

#include <boost/algorithm/string/predicate.hpp>

namespace valhalla {
namespace baldr {

Expand All @@ -22,11 +20,13 @@ bool StreetName::operator==(const StreetName& rhs) const {
}

bool StreetName::StartsWith(const std::string& prefix) const {
return boost::algorithm::starts_with(value_, prefix);
size_t n = prefix.size();
return (value_.size() < n) ? false : prefix == value_.substr(0, n);
}

bool StreetName::EndsWith(const std::string& suffix) const {
return boost::algorithm::ends_with(value_, suffix);
size_t n = suffix.size();
return (value_.size() < n) ? false : suffix == value_.substr(value_.size() - n);
}

std::string StreetName::GetPreDir() const {
Expand Down
2 changes: 0 additions & 2 deletions src/baldr/streetname_us.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "baldr/streetname.h"
#include "baldr/streetname_us.h"

#include <boost/algorithm/string/predicate.hpp>

namespace valhalla {
namespace baldr {

Expand Down
3 changes: 3 additions & 0 deletions test/edgecollapser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <unordered_map>
#include <vector>

#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>

#include "baldr/directededge.h"
#include "baldr/graphreader.h"
#include "baldr/merge.h"
Expand Down
8 changes: 1 addition & 7 deletions valhalla/baldr/admininfo.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef VALHALLA_BALDR_ADMININFO_H_
#define VALHALLA_BALDR_ADMININFO_H_

#include <boost/functional/hash.hpp>
#include <iostream>
#include <valhalla/baldr/admin.h>

Expand Down Expand Up @@ -73,12 +72,7 @@ class AdminInfo {

struct AdminInfoHasher {
std::size_t operator()(const AdminInfo& ai) const {
std::size_t seed = 13;
boost::hash_combine(seed, string_hasher(ai.country_iso_));
boost::hash_combine(seed, string_hasher(ai.country_text_));
boost::hash_combine(seed, string_hasher(ai.state_iso_));
boost::hash_combine(seed, string_hasher(ai.state_text_));
return seed;
return string_hasher(ai.country_iso_ + ai.country_text_ + ai.state_iso_ + ai.state_text_);
}
// function to hash string
std::hash<std::string> string_hasher;
Expand Down
4 changes: 1 addition & 3 deletions valhalla/baldr/tilehierarchy.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef VALHALLA_MIDGARD_TILEHIERARCHY_H
#define VALHALLA_MIDGARD_TILEHIERARCHY_H

#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <cstdint>
#include <map>
#include <string>
Expand All @@ -16,7 +14,7 @@ namespace valhalla {
namespace baldr {

/**
* TileLevel: Define a level in the hierarchy of the tiles. Includes:
* TileLevel: Defines a level in the hierarchy of the tiles. Includes:
* Hierarchy level.
* Minimum (largest value) road class in this level.
* Name for the level.
Expand Down

0 comments on commit 47555cc

Please sign in to comment.