From 818aabdbc555e935e0638233974e4c10b4dbb5f7 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Sun, 10 Nov 2019 13:26:24 -0500 Subject: [PATCH] Don't duplicate the split function logic in [modify_unit] --- data/lua/wml/modify_unit.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/data/lua/wml/modify_unit.lua b/data/lua/wml/modify_unit.lua index 4a8d6ed4ac9..ca0a3d3fd5a 100644 --- a/data/lua/wml/modify_unit.lua +++ b/data/lua/wml/modify_unit.lua @@ -7,12 +7,13 @@ local wml_actions = wesnoth.wml_actions -- in the first part of this file and the fallback (old) implementation in the -- second part of this file -local function split_to_array(str, sep) +local function split_to_array(str) -- Split string @str into a table using the delimiter @sep (default: ',') - local sep, fields = sep or ",", {} - local pattern = string.format("([^%s]+)", sep) - string.gsub(str, pattern, function(c) fields[#fields+1] = c end) + local fields = {} + for c in utils.split(str) do + fields[#fields+1] = c + end return fields end