[vala/staging] codewriter: Use List.sort() instead of custom local implementation



commit ae52240451e069e80cf8cf7ae858c4f8ecf754b9
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Sep 18 17:24:07 2018 +0200

    codewriter: Use List.sort() instead of custom local implementation

 vala/valacodewriter.vala | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
---
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<Symbol> ();
-               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);
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]