summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-16 19:32:56 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-18 10:38:49 +0100
commit6c91c3e51979c2141a21c0c1ca77230942f38b29 (patch)
treebc0e37dde93f18d736d66dd19f3f734d7d7d1e16
parentd959fe1522d3a96d85fd03f5a5deee318c733b75 (diff)
downloadqtlocation-mapboxgl-6c91c3e51979c2141a21c0c1ca77230942f38b29.tar.gz
[core] replace <regex> usage with plain string code to reduce binary size
-rw-r--r--src/mbgl/util/mapbox.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp
index 9cf250f7a3..89f6a55167 100644
--- a/src/mbgl/util/mapbox.cpp
+++ b/src/mbgl/util/mapbox.cpp
@@ -5,7 +5,6 @@
#include <stdexcept>
#include <vector>
#include <iostream>
-#include <regex>
namespace {
@@ -192,14 +191,22 @@ std::string canonicalizeTileURL(const std::string& url, SourceType type, uint16_
}
result += "." + extension;
-
+
// get the query and remove access_token, if more parameters exist, add them to the final result
if (queryIdx != url.length()) {
- const auto query = url.substr(queryIdx + 1);
- std::regex re ("&?access_token=([^&]*)");
- std::string replace = std::regex_replace(query, re, "");
- std::string subQuery = (replace.find("&") == 0) ? replace.substr(1, replace.length()) : replace;
- if (subQuery.length() > 0) result += "?" + subQuery;
+ auto idx = queryIdx;
+ bool hasQuery = false;
+ while (idx != std::string::npos) {
+ idx++; // skip & or ?
+ auto ampersandIdx = url.find("&", idx);
+ if (url.substr(idx, 13) != "access_token=") {
+ result += hasQuery ? "&" : "?";
+ result += url.substr(idx, ampersandIdx != std::string::npos ? ampersandIdx - idx
+ : std::string::npos);
+ hasQuery = true;
+ }
+ idx = ampersandIdx;
+ }
}
return result;