Skip to content

Commit d8e6735

Browse files
committed
---
yaml --- r: 1132 b: refs/heads/master c: 3504f4a h: refs/heads/master v: v3
1 parent 1230ac6 commit d8e6735

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 744b164b7dafbecd84e6f11e139ca054c283e77c
2+
refs/heads/master: 3504f4a4bf492886aa6cc7b2eae5d8e0100e9d51

trunk/src/comp/middle/typeck.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ fn collect_item_types(@ast.crate crate) -> tup(@ast.crate, @ty_table) {
248248
auto methods =
249249
_vec.map[@ast.method,method](f, obj_info.methods);
250250

251+
fn method_lteq(&method a, &method b) -> bool {
252+
ret _str.lteq(a.ident, b.ident);
253+
}
254+
255+
methods = std.sort.merge_sort[method](bind method_lteq(_,_),
256+
methods);
257+
251258
auto t_obj = plain_ty(ty.ty_obj(methods));
252259
ret t_obj;
253260
}

trunk/src/lib/_str.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ fn eq(&str a, &str b) -> bool {
2727
ret true;
2828
}
2929

30+
fn lteq(&str a, &str b) -> bool {
31+
let uint i = byte_len(a);
32+
let uint j = byte_len(b);
33+
let uint n = i;
34+
if (j < n) {
35+
n = j;
36+
}
37+
38+
let uint x = 0u;
39+
while (x < n) {
40+
auto cha = a.(x);
41+
auto chb = b.(x);
42+
if (cha <= chb) {
43+
ret true;
44+
}
45+
else if (cha > chb) {
46+
ret false;
47+
}
48+
x += 1u;
49+
}
50+
51+
ret i <= j;
52+
}
53+
54+
3055
fn hash(&str s) -> uint {
3156
// djb hash.
3257
// FIXME: replace with murmur.

0 commit comments

Comments
 (0)