[tracker-miners/wip/carlosg/speed-track: 1/40] libtracker-miner: Use g_file_equal() to check for file equality




commit 4c7b7d5ec3ce417fc3252dda852b423bc7b7f2ac
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Oct 3 14:11:08 2020 +0200

    libtracker-miner: Use g_file_equal() to check for file equality
    
    This is about the only place where we do actually rely on TrackerFileSystem
    using "const" pointers to the same GFile above TrackerFileNotifier. It's
    actually not that much of a hotspot, so use g_file_equal() here, and check
    it early in the function to make it easier to read.

 src/libtracker-miner/tracker-miner-fs.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 2c1742545..ade945912 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -729,40 +729,37 @@ queue_event_coalesce (const QueueEvent  *first,
                      const QueueEvent  *second,
                      QueueEvent       **replacement)
 {
+       if (!g_file_equal (first->file, second->file))
+               return QUEUE_ACTION_NONE;
+
        *replacement = NULL;
 
        if (first->type == TRACKER_MINER_FS_EVENT_CREATED) {
-               if ((second->type == TRACKER_MINER_FS_EVENT_UPDATED ||
-                    second->type == TRACKER_MINER_FS_EVENT_CREATED) &&
-                   first->file == second->file) {
+               if (second->type == TRACKER_MINER_FS_EVENT_UPDATED ||
+                    second->type == TRACKER_MINER_FS_EVENT_CREATED) {
                        return QUEUE_ACTION_DELETE_SECOND;
-               } else if (second->type == TRACKER_MINER_FS_EVENT_MOVED &&
-                          first->file == second->file) {
+               } else if (second->type == TRACKER_MINER_FS_EVENT_MOVED) {
                        *replacement = queue_event_new (TRACKER_MINER_FS_EVENT_CREATED,
                                                        second->dest_file);
                        return (QUEUE_ACTION_DELETE_FIRST |
                                QUEUE_ACTION_DELETE_SECOND);
-               } else if (second->type == TRACKER_MINER_FS_EVENT_DELETED &&
-                          first->file == second->file) {
+               } else if (second->type == TRACKER_MINER_FS_EVENT_DELETED) {
                        /* We can't be sure that "create" is replacing a file
                         * here. Preserve the second event just in case.
                         */
                        return QUEUE_ACTION_DELETE_FIRST;
                }
        } else if (first->type == TRACKER_MINER_FS_EVENT_UPDATED) {
-               if (second->type == TRACKER_MINER_FS_EVENT_UPDATED &&
-                   first->file == second->file) {
+               if (second->type == TRACKER_MINER_FS_EVENT_UPDATED) {
                        if (first->attributes_update && !second->attributes_update)
                                return QUEUE_ACTION_DELETE_FIRST;
                        else
                                return QUEUE_ACTION_DELETE_SECOND;
-               } else if (second->type == TRACKER_MINER_FS_EVENT_DELETED &&
-                          first->file == second->file) {
+               } else if (second->type == TRACKER_MINER_FS_EVENT_DELETED) {
                        return QUEUE_ACTION_DELETE_FIRST;
                }
        } else if (first->type == TRACKER_MINER_FS_EVENT_MOVED) {
-               if (second->type == TRACKER_MINER_FS_EVENT_MOVED &&
-                   first->dest_file == second->file) {
+               if (second->type == TRACKER_MINER_FS_EVENT_MOVED) {
                        if (first->file != second->dest_file) {
                                *replacement = queue_event_moved_new (first->file,
                                                                      second->dest_file);
@@ -770,8 +767,7 @@ queue_event_coalesce (const QueueEvent  *first,
 
                        return (QUEUE_ACTION_DELETE_FIRST |
                                QUEUE_ACTION_DELETE_SECOND);
-               } else if (second->type == TRACKER_MINER_FS_EVENT_DELETED &&
-                          first->dest_file == second->file) {
+               } else if (second->type == TRACKER_MINER_FS_EVENT_DELETED) {
                        *replacement = queue_event_new (TRACKER_MINER_FS_EVENT_DELETED,
                                                        first->file);
                        return (QUEUE_ACTION_DELETE_FIRST |


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]