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:
Andrew Borodin 2011-09-21 14:44:03 +04:00 committed by Slava Zanko
parent 8f4b9e32f1
commit 6dabcb5f55

View File

@ -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;
}
/* --------------------------------------------------------------------------------------------- */