Commit 411527a2 authored by Max Kellermann's avatar Max Kellermann

db/upnp: don't use stringToTokens() in ParseDuration()

Reduce bloat.
parent 7777057d
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "Tags.hxx" #include "Tags.hxx"
#include "tag/TagBuilder.hxx" #include "tag/TagBuilder.hxx"
#include "tag/TagTable.hxx" #include "tag/TagTable.hxx"
#include "util/NumberParser.hxx"
#include <algorithm> #include <algorithm>
#include <string> #include <string>
...@@ -45,12 +46,27 @@ ParseItemClass(const char *name) ...@@ -45,12 +46,27 @@ ParseItemClass(const char *name)
gcc_pure gcc_pure
static int static int
ParseDuration(const std::string &duration) ParseDuration(const char *duration)
{ {
const auto v = stringToTokens(duration, ":"); char *endptr;
if (v.size() != 3)
unsigned result = ParseUnsigned(duration, &endptr);
if (endptr == duration || *endptr != ':')
return 0;
result *= 60;
duration = endptr + 1;
result += ParseUnsigned(duration, &endptr);
if (endptr == duration || *endptr != ':')
return 0; return 0;
return atoi(v[0].c_str())*3600 + atoi(v[1].c_str())*60 + atoi(v[2].c_str());
result *= 60;
duration = endptr + 1;
result += ParseUnsigned(duration, &endptr);
if (endptr == duration || *endptr != 0)
return 0;
return result;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment