A reference to the comma-separated string of badges to deduplicate in place.
The badge to deduplicate.
{ string badges = "subscriber/14,subscriber/12,bits/30000"; deduplicateBadges(badges, "subscriber/"); assert((badges == "subscriber/14,bits/30000"), badges); } { string badges = "subscriber/1,subscriber/0"; deduplicateBadges(badges, "subscriber/"); assert((badges == "subscriber/1"), badges); } { string badges = "vip/1,subscriber/19,subscriber/17,partner/1"; deduplicateBadges(badges, "subscriber/"); assert((badges == "vip/1,subscriber/19,partner/1"), badges); } { string badges = "subscriber/28,broadcaster/1,subscriber/12,partner/1"; deduplicateBadges(badges, "subscriber/"); assert((badges == "subscriber/28,broadcaster/1,partner/1"), badges); } { string badges; deduplicateBadges(badges, string.init); assert(!badges.length, badges); }
Deduplicates a badge in a comma-separated list of badges.
Note: This only removes one duplicate badge, if present. It can trivially be made recursive.