From b2787e81a8a841b1e93574c4ea8889afbaed5330 Mon Sep 17 00:00:00 2001 From: Szymon Soczewka Date: Thu, 3 Nov 2022 11:27:55 +0100 Subject: [PATCH] Use concat instead of << to merge two arrays together. This way we won't create nested arrays, plus it's faster. --- lib/faker/sports/sport.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/faker/sports/sport.rb b/lib/faker/sports/sport.rb index cc83b15b28..0de39ec0d5 100644 --- a/lib/faker/sports/sport.rb +++ b/lib/faker/sports/sport.rb @@ -22,9 +22,15 @@ class << self # # @faker.version next def sport(include_ancient: false, include_unusual: false) - sports = fetch_all('sport.summer_olympics') + fetch_all('sport.winter_olympics') + fetch_all('sport.summer_paralympics') + fetch_all('sport.winter_paralympics') - sports << fetch_all('sport.ancient_olympics') if include_ancient - sports << fetch_all('sport.unusual') if include_unusual + sports = [] + sports.concat( + fetch_all('sport.summer_olympics'), + fetch_all('sport.summer_paralympics'), + fetch_all('sport.winter_olympics'), + fetch_all('sport.winter_paralympics') + ) + sports.concat(fetch_all('sport.ancient_olympics')) if include_ancient + sports.concat(fetch_all('sport.unusual')) if include_unusual sample(sports) end