From: Rico Tzschichholz Date: Tue, 18 Sep 2018 15:24:07 +0000 (+0200) Subject: codewriter: Use List.sort() instead of custom local implementation X-Git-Tag: 0.43.1~235 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae52240451e069e80cf8cf7ae858c4f8ecf754b9;p=thirdparty%2Fvala.git codewriter: Use List.sort() instead of custom local implementation --- diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index a65956133..43b4312f6 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -299,25 +299,8 @@ public class Vala.CodeWriter : CodeVisitor { } var sorted_symbols = new ArrayList (); - foreach (Symbol sym in symbols) { - int left = 0; - int right = sorted_symbols.size - 1; - if (left > right || sym.name < sorted_symbols[left].name) { - sorted_symbols.insert (0, sym); - } else if (sym.name > sorted_symbols[right].name) { - sorted_symbols.add (sym); - } else { - while (right - left > 1) { - int i = (right + left) / 2; - if (sym.name > sorted_symbols[i].name) { - left = i; - } else { - right = i; - } - } - sorted_symbols.insert (left + 1, sym); - } - } + sorted_symbols.add_all (symbols); + sorted_symbols.sort ((a, b) => strcmp (a.name, b.name)); foreach (Symbol sym in sorted_symbols) { sym.accept (this); }