mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-18 17:29:28 +03:00
VFS small optimization
(vfs_class_data_find_by_handle, vfs_class_find_by_handle): move same code to the separate function vfs_get_openfile(). Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
8f4b9e32f1
commit
6dabcb5f55
@ -168,6 +168,25 @@ _vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer
|
||||
return state;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static struct vfs_openfile *
|
||||
vfs_get_openfile (int handle)
|
||||
{
|
||||
struct vfs_openfile *h;
|
||||
|
||||
if (handle < VFS_FIRST_HANDLE || (guint) (handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
|
||||
return NULL;
|
||||
|
||||
h = (struct vfs_openfile *) g_ptr_array_index (vfs_openfiles, handle - VFS_FIRST_HANDLE);
|
||||
if (h == NULL)
|
||||
return NULL;
|
||||
|
||||
g_assert (h->handle == handle);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -198,16 +217,9 @@ vfs_class_data_find_by_handle (int handle)
|
||||
{
|
||||
struct vfs_openfile *h;
|
||||
|
||||
if (handle < VFS_FIRST_HANDLE || (guint) (handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
|
||||
return NULL;
|
||||
h = vfs_get_openfile (handle);
|
||||
|
||||
h = (struct vfs_openfile *) g_ptr_array_index (vfs_openfiles, handle - VFS_FIRST_HANDLE);
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
g_assert (h->handle == handle);
|
||||
|
||||
return h->fsinfo;
|
||||
return h == NULL ? NULL : h->fsinfo;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -218,16 +230,9 @@ vfs_class_find_by_handle (int handle)
|
||||
{
|
||||
struct vfs_openfile *h;
|
||||
|
||||
if (handle < VFS_FIRST_HANDLE || (guint) (handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
|
||||
return NULL;
|
||||
h = vfs_get_openfile (handle);
|
||||
|
||||
h = (struct vfs_openfile *) g_ptr_array_index (vfs_openfiles, handle - VFS_FIRST_HANDLE);
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
g_assert (h->handle == handle);
|
||||
|
||||
return h->vclass;
|
||||
return h == NULL ? NULL : h->vclass;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user