Remove default Geary.EmailIdentifier::hash and ::equal_to impls
Make subclasses implement these themselves and remove the unique string property, to be (hopefully) more efficient and easier for subclasses to specialise.
This commit is contained in:
parent
981ea845f4
commit
cb16bdc59d
4 changed files with 69 additions and 33 deletions
|
|
@ -12,17 +12,35 @@ public class Geary.MockEmailIdentifer : EmailIdentifier {
|
|||
|
||||
|
||||
public MockEmailIdentifer(int id) {
|
||||
base(id.to_string());
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public override uint hash() {
|
||||
return GLib.int_hash(this.id);
|
||||
}
|
||||
|
||||
public override bool equal_to(Geary.EmailIdentifier other) {
|
||||
return (
|
||||
this.get_type() == other.get_type() &&
|
||||
this.id == ((MockEmailIdentifer) other).id
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public override string to_string() {
|
||||
return "%s(%d)".printf(
|
||||
this.get_type().name(),
|
||||
this.id
|
||||
);
|
||||
}
|
||||
|
||||
public override GLib.Variant to_variant() {
|
||||
return new GLib.Variant.int32(id);
|
||||
}
|
||||
|
||||
public override int natural_sort_comparator(Geary.EmailIdentifier other) {
|
||||
MockEmailIdentifer? other_mock = other as MockEmailIdentifer;
|
||||
return (other_mock == null) ? 1 : this.id - other_mock.id;
|
||||
}
|
||||
|
||||
public override GLib.Variant to_variant() {
|
||||
return new GLib.Variant.int32(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue