diff options
author | Max Kellermann <max@duempel.org> | 2015-11-11 15:27:56 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-11-11 15:27:56 +0100 |
commit | c513478c31c8543309da5f04bb472ea6e4969603 (patch) | |
tree | a97d8641218738ea7348bc39cf2f5dd95cd04aa8 /src/db/plugins/simple/DatabaseSave.cxx | |
parent | a944927b56b49842ee91cc1bff3ecac6aeb214fc (diff) | |
download | mpd-c513478c31c8543309da5f04bb472ea6e4969603.tar.gz mpd-c513478c31c8543309da5f04bb472ea6e4969603.tar.xz mpd-c513478c31c8543309da5f04bb472ea6e4969603.zip |
db/simple: use StringAfterPrefix() instead of StringStartsWith()
Diffstat (limited to 'src/db/plugins/simple/DatabaseSave.cxx')
-rw-r--r-- | src/db/plugins/simple/DatabaseSave.cxx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/db/plugins/simple/DatabaseSave.cxx b/src/db/plugins/simple/DatabaseSave.cxx index 3955cc037..bec005828 100644 --- a/src/db/plugins/simple/DatabaseSave.cxx +++ b/src/db/plugins/simple/DatabaseSave.cxx @@ -86,8 +86,10 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error) while ((line = file.ReadLine()) != nullptr && strcmp(line, DIRECTORY_INFO_END) != 0) { - if (StringStartsWith(line, DB_FORMAT_PREFIX)) { - format = atoi(line + sizeof(DB_FORMAT_PREFIX) - 1); + const char *p; + + if ((p = StringAfterPrefix(line, DB_FORMAT_PREFIX))) { + format = atoi(p); } else if (StringStartsWith(line, DIRECTORY_MPD_VERSION)) { if (found_version) { error.Set(db_domain, "Duplicate version line"); @@ -95,9 +97,7 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error) } found_version = true; - } else if (StringStartsWith(line, DIRECTORY_FS_CHARSET)) { - const char *new_charset; - + } else if ((p = StringAfterPrefix(line, DIRECTORY_FS_CHARSET))) { if (found_charset) { error.Set(db_domain, "Duplicate charset line"); return false; @@ -105,7 +105,7 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error) found_charset = true; - new_charset = line + sizeof(DIRECTORY_FS_CHARSET) - 1; + const char *new_charset = p; const char *const old_charset = GetFSCharset(); if (*old_charset != 0 && strcmp(new_charset, old_charset) != 0) { @@ -116,8 +116,8 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error) new_charset, old_charset); return false; } - } else if (StringStartsWith(line, DB_TAG_PREFIX)) { - const char *name = line + sizeof(DB_TAG_PREFIX) - 1; + } else if ((p = StringAfterPrefix(line, DB_TAG_PREFIX))) { + const char *name = p; TagType tag = tag_name_parse(name); if (tag == TAG_NUM_OF_ITEM_TYPES) { error.Format(db_domain, |