From 801e33204bb7c8b1bcaf90ebe3e004c612586ce1 Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 27 Jan 2021 15:38:30 +0700 Subject: [PATCH] fix MirStringTable --- source/mir/string_table.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/mir/string_table.d b/source/mir/string_table.d index e0f6f32..c309eb1 100644 --- a/source/mir/string_table.d +++ b/source/mir/string_table.d @@ -119,7 +119,7 @@ struct MirStringTable(size_t length, size_t maxKeyLength, bool caseInsensetive = The constructor uses GC. It can be used in `@nogc` code when if constructed in compile time. +/ - this()(immutable(C)[][length] sortedKeys) + this(immutable(C)[][length] sortedKeys) @trusted pure nothrow { pragma(inline, false); @@ -231,7 +231,11 @@ package template createTable(C) auto createTable(immutable(C)[][] keys, bool caseInsensetive = false)() { static immutable C[][] sortedKeys = prepareStringTableKeys!caseInsensetive(keys); - return MirStringTable!(keys.length, sortedKeys.length ? sortedKeys[$ - 1].length : 0, caseInsensetive, C)(sortedKeys[0 .. sortedKeys.length]); + alias Table = MirStringTable!(sortedKeys.length, sortedKeys.length ? sortedKeys[$ - 1].length : 0, caseInsensetive, C); + static if (sortedKeys.length) + return Table(sortedKeys[0 .. sortedKeys.length]); + else + return Table.init; } }