summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2017-10-24 22:34:01 +0200
committerCarlos Garnacho <carlosg@gnome.org>2017-10-24 22:34:01 +0200
commit23a233c93168b42d82553d77e3dd003b87a6c339 (patch)
tree4558346cfb853d2f6650c5c8abf20c8a0aa70955
parentf0a3ae7ec91ee8d652c904e9aa9a30313f627484 (diff)
downloadtracker-23a233c93168b42d82553d77e3dd003b87a6c339.tar.gz
libtracker-miner: Pass parent to _insert_store_info()
As both places doing this iterate directories one by one, we can optimize GFile interning by providing an already interned common parent. This eases the GNode lookups in TrackerFileSystem, as we already know the most direct parent GNode the file should have.
-rw-r--r--src/libtracker-miner/tracker-file-notifier.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 1b3028cd1..7d38eb33f 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -483,6 +483,7 @@ static GFile *
_insert_store_info (TrackerFileNotifier *notifier,
GFile *file,
GFileType file_type,
+ GFile *parent,
const gchar *iri,
guint64 _time)
{
@@ -492,7 +493,7 @@ _insert_store_info (TrackerFileNotifier *notifier,
priv = notifier->priv;
canonical = tracker_file_system_get_file (priv->file_system,
file, file_type,
- NULL);
+ parent);
tracker_file_system_set_property (priv->file_system, canonical,
quark_property_iri,
g_strdup (iri));
@@ -508,6 +509,7 @@ sparql_files_query_populate (TrackerFileNotifier *notifier,
gboolean check_root)
{
TrackerFileNotifierPrivate *priv;
+ GFile *parent = NULL;
priv = notifier->priv;
@@ -534,6 +536,10 @@ sparql_files_query_populate (TrackerFileNotifier *notifier,
}
}
+ /* All files belong to the same directory */
+ if (!parent)
+ parent = tracker_file_system_peek_parent (priv->file_system, file);
+
iri = tracker_sparql_cursor_get_string (cursor, 1, NULL);
time_str = tracker_sparql_cursor_get_string (cursor, 2, NULL);
_time = tracker_string_to_date (time_str, NULL, &error);
@@ -547,7 +553,7 @@ sparql_files_query_populate (TrackerFileNotifier *notifier,
_insert_store_info (notifier, file,
G_FILE_TYPE_UNKNOWN,
- iri, _time);
+ parent, iri, _time);
g_object_unref (file);
}
}
@@ -557,7 +563,7 @@ sparql_contents_check_deleted (TrackerFileNotifier *notifier,
TrackerSparqlCursor *cursor)
{
TrackerFileNotifierPrivate *priv;
- GFile *file, *canonical;
+ GFile *file, *canonical, *parent = NULL;
const gchar *iri;
priv = notifier->priv;
@@ -584,6 +590,10 @@ sparql_contents_check_deleted (TrackerFileNotifier *notifier,
file_type = is_folder ? G_FILE_TYPE_DIRECTORY : G_FILE_TYPE_UNKNOWN;
canonical = tracker_file_system_peek_file (priv->file_system, file);
+ /* All files belong to the same directory */
+ if (!parent)
+ parent = tracker_file_system_peek_parent (priv->file_system, file);
+
if (!canonical) {
/* The file exists on the store, but not on the
* crawled content, insert temporarily to handle
@@ -591,7 +601,7 @@ sparql_contents_check_deleted (TrackerFileNotifier *notifier,
*/
canonical = _insert_store_info (notifier, file,
file_type,
- iri, 0);
+ parent, iri, 0);
g_signal_emit (notifier, signals[FILE_DELETED], 0, canonical);
} else if (priv->current_index_root->current_dir_content_filtered ||
!tracker_indexing_tree_file_is_indexable (priv->indexing_tree,