replace [0] with front() where applicable

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 3 years ago
parent 9fbcdb4841
commit 5d2d47032b

@ -1467,7 +1467,7 @@ void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, size_t from, s
// standardize the path without "/" at the beginning.
std::size_t protocolIndex = scriptPath.find("://");
if (protocolIndex == std::string::npos && scriptPath[0] != '/') {
if (protocolIndex == std::string::npos && scriptPath.front() != '/') {
scriptPath = "/" + scriptPath;
}
@ -1657,7 +1657,7 @@ void CurlIo::CurlImpl::writeRemote(const byte* data, size_t size, size_t from, s
// add the protocol and host to the path
std::size_t protocolIndex = scriptPath.find("://");
if (protocolIndex == std::string::npos) {
if (scriptPath[0] != '/')
if (scriptPath.front() != '/')
scriptPath = "/" + scriptPath;
scriptPath = hostInfo.Protocol + "://" + hostInfo.Host + scriptPath;
}

@ -475,7 +475,7 @@ void readWriteEpsMetadata(BasicIo& io, std::string& xmpPacket, NativePreviewList
#endif
// implicit comments
if (line == "%%EOF" || line == "%begin_xml_code" ||
!(line.size() >= 2 && line[0] == '%' && '\x21' <= line[1] && line[1] <= '\x7e')) {
!(line.size() >= 2 && line.front() == '%' && '\x21' <= line[1] && line[1] <= '\x7e')) {
if (posEndComments == posEndEps) {
posEndComments = startPos;
#ifdef DEBUG
@ -492,20 +492,21 @@ void readWriteEpsMetadata(BasicIo& io, std::string& xmpPacket, NativePreviewList
#endif
}
if (posBeginPageSetup == posEndEps &&
(implicitPage || (posPage != posEndEps && !inRemovableEmbedding && !line.empty() && line[0] != '%'))) {
(implicitPage || (posPage != posEndEps && !inRemovableEmbedding && !line.empty() && line.front() != '%'))) {
posBeginPageSetup = startPos;
implicitPageSetup = true;
#ifdef DEBUG
EXV_DEBUG << "readWriteEpsMetadata: Found implicit BeginPageSetup at position: " << startPos << "\n";
#endif
}
if (posEndPageSetup == posEndEps && implicitPageSetup && !inRemovableEmbedding && !line.empty() && line[0] != '%') {
if (posEndPageSetup == posEndEps && implicitPageSetup && !inRemovableEmbedding && !line.empty() &&
line.front() != '%') {
posEndPageSetup = startPos;
#ifdef DEBUG
EXV_DEBUG << "readWriteEpsMetadata: Found implicit EndPageSetup at position: " << startPos << "\n";
#endif
}
if (!line.empty() && line[0] != '%')
if (!line.empty() && line.front() != '%')
continue; // performance optimization
if (line == "%%EOF" || line == "%%Trailer" || line == "%%PageTrailer") {
if (posBeginPageSetup == posEndEps) {

@ -120,7 +120,7 @@ const TiffMnRegistry TiffMnCreator::registry_[] = {
bool TiffMnRegistry::operator==(const std::string& key) const {
std::string make(make_);
if (!key.empty() && key[0] == '-')
if (!key.empty() && key.front() == '-')
return false;
return make == key.substr(0, make.length());
}

@ -31,8 +31,8 @@ std::ostream& printVersion(std::ostream& os, const std::string& str) {
if (str.size() != 4) {
return os << "(" << str << ")";
}
if (str[0] != '0')
os << str[0];
if (str.front() != '0')
os << str.front();
return os << str[1] << "." << str[2] << str[3];
}
} // namespace

@ -323,7 +323,7 @@ int CommentValue::read(const std::string& comment) {
const std::string::size_type pos = comment.find_first_of(' ');
std::string name = comment.substr(8, pos - 8);
// Strip quotes (so you can also specify the charset without quotes)
if (!name.empty() && name[0] == '"')
if (!name.empty() && name.front() == '"')
name = name.substr(1);
if (!name.empty() && name[name.length() - 1] == '"')
name = name.substr(0, name.length() - 1);
@ -499,7 +499,7 @@ int XmpTextValue::read(const std::string& buf) {
std::string::size_type pos = buf.find_first_of(' ');
type = buf.substr(5, pos - 5);
// Strip quotes (so you can also specify the type without quotes)
if (!type.empty() && type[0] == '"')
if (!type.empty() && type.front() == '"')
type = type.substr(1);
if (!type.empty() && type[type.length() - 1] == '"')
type = type.substr(0, type.length() - 1);
@ -662,7 +662,7 @@ int LangAltValue::read(const std::string& buf) {
if (lang.empty())
throw Error(ErrorCode::kerInvalidLangAltValue, buf);
// Strip quotes (so you can also specify the language without quotes)
if (lang[0] == '"') {
if (lang.front() == '"') {
lang = lang.substr(1);
if (lang.empty() || lang.find('"') != lang.length() - 1)

Loading…
Cancel
Save