Skip to content

Commit

Permalink
Eliminate use of string_view::at
Browse files Browse the repository at this point in the history
We only use it in once place. At that point we can guarantee we stay in-bounds. So there is no need to use at() to check we remain in-bounds.

This eliminates a warning when building Debug for Windows (quieting Appveyor).

AI0886 had a similar issue building using GCC 6.3 on Boost 1.62

Reverting ca03818 and 0cbab6e since this changeset should correct both issues.
  • Loading branch information
GregoryLundberg authored and Vultraz committed Nov 29, 2017
1 parent 230dce9 commit 4dbe4fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/font/text.cpp
Expand Up @@ -771,7 +771,7 @@ std::vector<std::string> pango_text::find_links(utils::string_view text) const {

int last_delim = -1;
for (size_t index = 0; index < text.size(); ++index) {
if (delim.find(text.at(index)) != std::string::npos) {
if (delim.find(text[index]) != std::string::npos) {
// want to include chars from range since last token, dont want to include any delimiters
utils::string_view token = text.substr(last_delim + 1, index - last_delim - 1);
if(looks_like_url(token)) {
Expand Down
9 changes: 1 addition & 8 deletions src/serialization/string_view.hpp
Expand Up @@ -21,14 +21,7 @@ that class. */

#include <boost/version.hpp>

/*
* Earlier versions already have string_view, but fail to compile on some
* compilers. The problem is that in string_view::at's ternary expression,
* BOOST_THROW_EXCEPTION is not seen as a throw-expression. If a ternary branch
* is not a throw-expression, it must be of the same type as the other branch,
* necessitating the ', res[0]' workaround.
*/
#if BOOST_VERSION >= 106400
#if BOOST_VERSION > 106100

/* Boost string_view is available, so we can just use it. */
#include <boost/utility/string_view.hpp>
Expand Down

0 comments on commit 4dbe4fb

Please sign in to comment.