1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-01-11 05:48:01 -05:00

* avoid calls to File.length() if possible

This commit is contained in:
Reinhard Pointner 2009-07-24 21:16:29 +00:00
parent 6d8c82df90
commit b109e54db4

View File

@ -61,6 +61,13 @@ class MatchAction extends AbstractAction {
// 1. pass: match by file length (fast, but only works when matching torrents or files) // 1. pass: match by file length (fast, but only works when matching torrents or files)
metrics[0] = new LengthEqualsMetric() { metrics[0] = new LengthEqualsMetric() {
@Override
public float getSimilarity(Object o1, Object o2) {
// order of arguments is logically irrelevant, but we might be able to save us a call to File.length() this way
return o1 instanceof File ? super.getSimilarity(o2, o1) : super.getSimilarity(o1, o2);
}
@Override @Override
protected long getLength(Object object) { protected long getLength(Object object) {
if (object instanceof AbstractFile) { if (object instanceof AbstractFile) {