# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1556902778 -7200
# Node ID f5ea0b886c7c11784784a53b2a82b2868cef5de1
# Parent  8a93af85f3190c54417da5d595aafdb906443881
mod_storage_xmlarchive: Limit search to smallest time range in case of inexact match

This should improve performance in case the exact days in the 'start'
and 'end' range are missing from the index.

diff -r 8a93af85f319 -r f5ea0b886c7c mod_storage_xmlarchive/mod_storage_xmlarchive.lua
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Thu May 02 20:43:05 2019 +0100
+++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Fri May 03 18:59:38 2019 +0200
@@ -110,7 +110,7 @@
 	if query.start then
 		local d = dt.date(query.start);
 		for i = 1, #dates do
-			if dates[i] == d then
+			if dates[i] >= d then
 				start_day = i; break;
 			end
 		end
@@ -118,7 +118,7 @@
 	if query["end"] then
 		local d = dt.date(query["end"]);
 		for i = #dates, 1, -1 do
-			if dates[i] == d then
+			if dates[i] <= d then
 				last_day = i; break;
 			end
 		end