querystring: do not display separator for empty array stringify

Currently, stringification of an empty array outputs a single separator character. This commit causes an empty array to output the empty string. Also removed an unnecessary `if` statement. Related to #7971
Do not cache `keys.length`, there is no point in it.