Skip to content

Commit

Permalink
Speed up EPG loading
Browse files Browse the repository at this point in the history
With kodi-pvr#269 there are three regex which are evaluated on every function call. In my case loading time was increased from 800msec to 10sec. This PR replaces those regex with static one and brings time down to 530msec.
  • Loading branch information
vpeter4 committed Sep 22, 2019
1 parent a19d662 commit fbc765a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pvr.iptvsimple/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.iptvsimple"
version="3.8.2"
version="3.8.3"
name="PVR IPTV Simple Client"
provider-name="nightik">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
3 changes: 3 additions & 0 deletions pvr.iptvsimple/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v3.8.3
- Speed up EPG loading

v3.8.2
- Update github wiki link in addon.xml

Expand Down
9 changes: 6 additions & 3 deletions src/PVRIptvData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ PVRIptvData::~PVRIptvData(void)

bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
{
static const std::regex dateRegex("^[1-9][0-9][0-9][0-9][0-9][1-9][0-9][1-9]");
auto started = std::chrono::high_resolution_clock::now();
XBMC->Log(LOG_DEBUG, "%s EPG Load Start", __FUNCTION__);

Expand Down Expand Up @@ -419,7 +420,7 @@ bool PVRIptvData::LoadEPG(time_t iStart, time_t iEnd)
GetNodeValue(pChannelNode, "date", dateString);
if (!dateString.empty())
{
if (std::regex_match(dateString, std::regex("^[1-9][0-9][0-9][0-9][0-9][1-9][0-9][1-9]")))
if (std::regex_match(dateString, dateRegex))
entry.firstAired = static_cast<time_t>(ParseDateTime(dateString));

std::sscanf(dateString.c_str(), "%04d", &entry.iYear);
Expand Down Expand Up @@ -534,10 +535,12 @@ bool PVRIptvData::ParseXmltvNsEpisodeNumberInfo(const std::string& episodeNumber

bool PVRIptvData::ParseOnScreenEpisodeNumberInfo(const std::string& episodeNumberString, PVRIptvEpgEntry& entry)
{
const std::string text = std::regex_replace(episodeNumberString, std::regex("[ \\txX_\\.]"), "");
static const std::regex numRegex("[ \\txX_\\.]");
static const std::regex epRegex("^[sS]([0-9][0-9]*)[eE][pP]?([0-9][0-9]*)$");
const std::string text = std::regex_replace(episodeNumberString, numRegex, "");

std::smatch match;
if (std::regex_match(text, match, std::regex("^[sS]([0-9][0-9]*)[eE][pP]?([0-9][0-9]*)$")))
if (std::regex_match(text, match, epRegex))
{
if (match.size() == 3)
{
Expand Down

0 comments on commit fbc765a

Please sign in to comment.