From 875a0552ae8c92fc7211e3affd3447d44219be0f Mon Sep 17 00:00:00 2001 From: hyche Date: Thu, 15 Jun 2017 01:16:21 +0700 Subject: [PATCH] BTRFS: Method _Compare from BTree is now in btrfs_key Signed-off-by: Adrien Destugues --- .../kernel/file_systems/btrfs/BTree.cpp | 24 +++++++++---------- src/add-ons/kernel/file_systems/btrfs/BTree.h | 2 -- src/add-ons/kernel/file_systems/btrfs/btrfs.h | 2 ++ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/add-ons/kernel/file_systems/btrfs/BTree.cpp b/src/add-ons/kernel/file_systems/btrfs/BTree.cpp index 85fda068cc..1033b80043 100644 --- a/src/add-ons/kernel/file_systems/btrfs/BTree.cpp +++ b/src/add-ons/kernel/file_systems/btrfs/BTree.cpp @@ -57,19 +57,19 @@ BTree::~BTree() int32 -BTree::_CompareKeys(btrfs_key& key1, btrfs_key& key2) +btrfs_key::Compare(const btrfs_key& key) const { - if (key1.ObjectID() > key2.ObjectID()) + if (ObjectID() > key.ObjectID()) return 1; - if (key1.ObjectID() < key2.ObjectID()) + if (ObjectID() < key.ObjectID()) return -1; - if (key1.Type() > key2.Type()) + if (Type() > key.Type()) return 1; - if (key1.Type() < key2.Type()) + if (Type() < key.Type()) return -1; - if (key1.Offset() > key2.Offset()) + if (Offset() > key.Offset()) return 1; - if (key1.Offset() < key2.Offset()) + if (Offset() < key.Offset()) return -1; return 0; } @@ -101,12 +101,12 @@ BTree::_Find(btrfs_key& key, void** _value, size_t* _size, TRACE("Find() level %d\n", stream->header.Level()); uint32 i = 1; for (; i < stream->header.ItemCount(); i++) { - int32 comp = _CompareKeys(stream->index[i].key, key); + int32 comp = key.Compare(stream->index[i].key); TRACE("Find() found index %" B_PRIu32 " at %" B_PRId64 " comp %" B_PRId32 "\n", i, stream->index[i].BlockNum(), comp); - if (comp < 0) + if (comp > 0) continue; - if (comp > 0 || type == BTREE_BACKWARD) + if (comp < 0 || type == BTREE_BACKWARD) break; } TRACE("Find() getting index %" B_PRIu32 " at %" B_PRId64 "\n", i - 1, @@ -125,7 +125,7 @@ BTree::_Find(btrfs_key& key, void** _value, size_t* _size, #ifdef TRACE_BTRFS TRACE("Find() dump count %" B_PRId32 "\n", stream->header.ItemCount()); for (i = 0; i < stream->header.ItemCount(); i++) { - int32 comp = _CompareKeys(key, stream->entries[i].key); + int32 comp = key.Compare(stream->entries[i].key); TRACE("Find() dump %" B_PRIu32 " %" B_PRIu32 " offset %" B_PRId64 " comp %" B_PRId32 "\n", stream->entries[i].Offset(), stream->entries[i].Size(), stream->entries[i].key.Offset(), comp); @@ -133,7 +133,7 @@ BTree::_Find(btrfs_key& key, void** _value, size_t* _size, #endif for (i = 0; i < stream->header.ItemCount(); i++) { - int32 comp = _CompareKeys(key, stream->entries[i].key); + int32 comp = key.Compare(stream->entries[i].key); TRACE("Find() found %" B_PRIu32 " %" B_PRIu32 " oid %" B_PRId64 " type %d offset %" B_PRId64 " comp %" B_PRId32 "\n", stream->entries[i].Offset(), stream->entries[i].Size(), diff --git a/src/add-ons/kernel/file_systems/btrfs/BTree.h b/src/add-ons/kernel/file_systems/btrfs/BTree.h index 56a8b6dca5..0559343b43 100644 --- a/src/add-ons/kernel/file_systems/btrfs/BTree.h +++ b/src/add-ons/kernel/file_systems/btrfs/BTree.h @@ -58,8 +58,6 @@ private: BTree& operator=(const BTree& other); // no implementation - int32 _CompareKeys(btrfs_key& key1, - btrfs_key& key2); status_t _Find(btrfs_key& key, void** value, size_t* size, btree_traversing type); void _AddIterator(TreeIterator* iterator); diff --git a/src/add-ons/kernel/file_systems/btrfs/btrfs.h b/src/add-ons/kernel/file_systems/btrfs/btrfs.h index 2afe5a9860..279c42c7ff 100644 --- a/src/add-ons/kernel/file_systems/btrfs/btrfs.h +++ b/src/add-ons/kernel/file_systems/btrfs/btrfs.h @@ -26,6 +26,8 @@ struct btrfs_key { void SetObjectID(uint64 id) { object_id = B_HOST_TO_LENDIAN_INT64(id); } void SetType(uint8 key_type) { type = key_type; } void SetOffset(uint64 off) { offset = B_HOST_TO_LENDIAN_INT64(off); } + int32 Compare(const btrfs_key& key) const; + //implemented in BTree.cpp } _PACKED;