From waddlesplash <waddlesplash@xxxxxxxxx>:
waddlesplash has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/2322 ;)
Change subject: Tracker: Replace the deprecated std::hash_set with our HashSet.
......................................................................
Tracker: Replace the deprecated std::hash_set with our HashSet.
---
M src/kits/tracker/PoseView.cpp
M src/kits/tracker/PoseView.h
2 files changed, 37 insertions(+), 33 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/22/2322/1
diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp
index 5a0a874..b5711c3 100644
--- a/src/kits/tracker/PoseView.cpp
+++ b/src/kits/tracker/PoseView.cpp
@@ -1905,8 +1905,8 @@
Model* model = models[modelIndex];
// pose adopts model and deletes it when done
- if (fInsertedNodes.find(*(model->NodeRef())) !=
fInsertedNodes.end()
- || FindZombie(model->NodeRef())) {
+ if (fInsertedNodes.Contains(*(model->NodeRef()))
+ || FindZombie(model->NodeRef())) {
watch_node(model->NodeRef(), B_STOP_WATCHING, this);
delete model;
if (resultingPoses)
@@ -1914,7 +1914,7 @@
continue;
} else
- fInsertedNodes.insert(*(model->NodeRef()));
+ fInsertedNodes.Add(*(model->NodeRef()));
if ((clipboardMode = FSClipboardFindNodeMode(model,
!clipboardLocked,
true)) != 0 && !HasPosesInClipboard()) {
@@ -8067,7 +8067,7 @@
pose = fPoseList->FindPose(itemNode, &index);
if (pose != NULL) {
- fInsertedNodes.erase(fInsertedNodes.find(*itemNode));
+ fInsertedNodes.Remove(*itemNode);
if (pose->TargetModel()->IsSymLink()) {
fBrokenLinks->RemoveItem(pose->TargetModel());
StopWatchingParentsOf(pose->TargetModel()->EntryRef());
@@ -8430,7 +8430,7 @@
// the new add_poses thread will then set fAddPosesThread to its ID and
it
// will be allowed to add icons
fAddPosesThreads.clear();
- fInsertedNodes.clear();
+ fInsertedNodes.Clear();
delete fModel;
fModel = model;
@@ -8511,14 +8511,12 @@
void
BPoseView::Refresh()
{
- BEntry entry;
-
ASSERT(TargetModel());
if (TargetModel()->OpenNode() != B_OK)
return;
StopWatching();
- fInsertedNodes.clear();
+ fInsertedNodes.Clear();
ClearPoses();
StartWatching();
diff --git a/src/kits/tracker/PoseView.h b/src/kits/tracker/PoseView.h
index 9d77138..ab82c9c 100644
--- a/src/kits/tracker/PoseView.h
+++ b/src/kits/tracker/PoseView.h
@@ -53,40 +53,17 @@
#include <Directory.h>
#include <FilePanel.h>
+#include <HashSet.h>
#include <MessageRunner.h>
#include <String.h>
#include <ScrollBar.h>
#include <View.h>
-#include <hash_set>
#include <set>
class BRefFilter;
class BList;
-#if __GNUC__ > 2
-namespace __gnu_cxx {
-template<>
-struct hash<node_ref>
-#else
-template<>
-struct std::hash<node_ref>
-#endif
-{
- size_t
- operator()(node_ref ref) const
- {
- return ref.node;
- }
-};
-#if __GNUC__ > 2
-} // namespace __gnu_cxx
-typedef __gnu_cxx::hash_set<node_ref, __gnu_cxx::hash<node_ref> > NodeSet;
-#else
-typedef std::hash_set<node_ref, std::hash<node_ref> > NodeSet;
-#endif
-
-
namespace BPrivate {
class BCountView;
@@ -700,6 +677,35 @@
void _ResetStartOffset();
protected:
+ struct node_ref_key {
+ node_ref_key() {}
+ node_ref_key(const node_ref& value) : value(value) {}
+
+ uint32 GetHashCode() const
+ {
+ return (uint32)value.device ^ (uint32)value.node;
+ }
+
+ node_ref_key operator=(const node_ref_key& other)
+ {
+ value = other.value;
+ return *this;
+ }
+
+ bool operator==(const node_ref_key& other) const
+ {
+ return (value == other.value);
+ }
+
+ bool operator!=(const node_ref_key& other) const
+ {
+ return (value != other.value);
+ }
+
+ node_ref value;
+ };
+
+protected:
TScrollBar* fHScrollBar;
BScrollBar* fVScrollBar;
Model* fModel;
@@ -710,7 +716,7 @@
PoseList* fFilteredPoseList;
PoseList* fVSPoseList;
PoseList* fSelectionList;
- NodeSet fInsertedNodes;
+ HashSet<node_ref_key> fInsertedNodes;
BObjectList<BString> fMimeTypesInSelectionCache;
// used for mime string based icon highliting during a drag
BObjectList<Model>* fZombieList;
--
To view, visit https://review.haiku-os.org/c/haiku/+/2322
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I7d29f0c905a3ab1a20f6eca252ff1f168218c23f
Gerrit-Change-Number: 2322
Gerrit-PatchSet: 1
Gerrit-Owner: waddlesplash <waddlesplash@xxxxxxxxx>
Gerrit-MessageType: newchange