Commit 8280d7a8 authored by Christian Hergert's avatar Christian Hergert
Browse files

code-index: remove dead code

parent 879ed40a
......@@ -206,108 +206,6 @@ ide_code_index_index_load (IdeCodeIndexIndex *self,
return TRUE;
* ide_code_index_index_load_if_nmod:
* @self: a #IdeCodeIndexIndex
* @directory: a #GFile of the directory to load
* @files: (element-type Gio.File): a #GPtrArray of #GFile
* @mod_time: the modified time
* @cancellable: (nullable): a #GCancellable or %NULL
* @error: a location for a #GError, or %NULL
* This function will load index from directory if it is not modified. This
* fuction will only load if all "files" (GPtrArray) and only those "files" are
* there in index.
* Returns: %TRUE if there were no modifications; otherwise %FALSE. It is possible
* for %FALSE to be returned and @error will not be set.
* Thread safety: You may call this function from a thread, given that the thread has
* it's own reference to @self.
ide_code_index_index_load_if_nmod (IdeCodeIndexIndex *self,
GFile *directory,
GPtrArray *files,
GTimeVal mod_time,
GCancellable *cancellable,
GError **error)
g_autoptr(DirectoryIndex) dir_index = NULL;
g_autoptr(GFileInfo) file_info = NULL;
g_autoptr(GFile) names_file = NULL;
g_autofree gchar *dir_name = NULL;
GTimeVal index_mod_time;
gpointer value = NULL;
g_return_val_if_fail (IDE_IS_CODE_INDEX_INDEX (self), FALSE);
g_return_val_if_fail (G_IS_FILE (directory), FALSE);
g_return_val_if_fail (files != NULL, FALSE);
if (!(dir_index = directory_index_new (directory, cancellable, error)))
return FALSE;
* Return false if current number of files in directory != number of files that are
* indexed previously in the same directory.
if (dzl_fuzzy_index_get_metadata_uint32 (dir_index->symbol_names, "n_files") != files->len)
return FALSE;
/* Return false if files are modified after they are indexed. */
names_file = g_file_get_child (directory, "SymbolNames");
file_info = g_file_query_info (names_file,
if (file_info == NULL)
return FALSE;
g_file_info_get_modification_time (file_info, &index_mod_time);
if ((mod_time.tv_sec > index_mod_time.tv_sec) ||
((mod_time.tv_sec == index_mod_time.tv_sec) &&
(mod_time.tv_usec > index_mod_time.tv_usec)))
return FALSE;
/* Return false if all current files in directory are not there in index. */
for (guint i = 0; i < files->len; i++)
GFile *file = g_ptr_array_index (files, i);
g_autofree gchar *path = g_file_get_path (file);
if (!dzl_fuzzy_index_get_metadata_uint32 (dir_index->symbol_names, path))
return FALSE;
dir_name = g_file_get_path (directory);
g_mutex_lock (&self->mutex);
if (g_hash_table_lookup_extended (self->directories, dir_name, NULL, &value))
guint i = GPOINTER_TO_UINT (value);
g_assert (i < self->indexes->len);
g_assert (self->indexes->len > 0);
directory_index_free (g_ptr_array_index (self->indexes, i));
g_ptr_array_index (self->indexes, i) = g_steal_pointer (&dir_index);
g_hash_table_insert (self->directories,
g_steal_pointer (&dir_name),
GUINT_TO_POINTER (self->indexes->len));
g_ptr_array_add (self->indexes, g_steal_pointer (&dir_index));
g_mutex_unlock (&self->mutex);
return TRUE;
/* Create a new IdeCodeIndexSearchResult based on match from fuzzy index */
static IdeCodeIndexSearchResult *
ide_code_index_index_create_search_result (IdeContext *context,
......@@ -27,12 +27,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeCodeIndexIndex, ide_code_index_index, IDE, CODE_INDEX_INDEX, IdeObject)
IdeCodeIndexIndex *ide_code_index_index_new (IdeContext *context);
gboolean ide_code_index_index_load_if_nmod (IdeCodeIndexIndex *self,
GFile *directory,
GPtrArray *files,
GTimeVal mod_time,
GCancellable *cancellable,
GError **error);
gboolean ide_code_index_index_load (IdeCodeIndexIndex *self,
GFile *directory,
GCancellable *cancellable,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment