You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/08/27 00:51:16 UTC
[lucy-commits] [3/7] git commit: refs/heads/cfish-string-prep1 - Eliminate CB_setf
in FSDirHandle
Eliminate CB_setf in FSDirHandle
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/5169be5e
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/5169be5e
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/5169be5e
Branch: refs/heads/cfish-string-prep1
Commit: 5169be5efa3c05255a3604eb92fdbda4c1b27b3b
Parents: 5ef340d
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Mon Aug 26 22:33:47 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Aug 27 00:46:55 2013 +0200
----------------------------------------------------------------------
core/Lucy/Store/FSDirHandle.c | 37 +++++++++++++++---------------------
core/Lucy/Store/FSDirHandle.cfh | 1 -
2 files changed, 15 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/5169be5e/core/Lucy/Store/FSDirHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSDirHandle.c b/core/Lucy/Store/FSDirHandle.c
index 369d118..abc92cc 100644
--- a/core/Lucy/Store/FSDirHandle.c
+++ b/core/Lucy/Store/FSDirHandle.c
@@ -212,8 +212,7 @@ FSDH_do_open(FSDirHandle *self, const CharBuf *dir) {
DH_init((DirHandle*)self, dir);
FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
- ivars->sys_dir_entry = NULL;
- ivars->fullpath = NULL;
+ ivars->sys_dir_entry = NULL;
ivars->sys_dirhandle = opendir(dir_path_ptr);
if (!ivars->sys_dirhandle) {
@@ -269,16 +268,15 @@ FSDH_Entry_Is_Dir_IMP(FSDirHandle *self) {
}
#endif
+ bool retval = false;
struct stat stat_buf;
- if (!ivars->fullpath) {
- ivars->fullpath = CB_new(CB_Get_Size(ivars->dir) + 20);
+ CharBuf *fullpath = CB_newf("%o%s%o", ivars->dir, CHY_DIR_SEP,
+ ivars->entry);
+ if (stat((char*)CB_Get_Ptr8(fullpath), &stat_buf) != -1) {
+ if (stat_buf.st_mode & S_IFDIR) { retval = true; }
}
- CB_setf(ivars->fullpath, "%o%s%o", ivars->dir, CHY_DIR_SEP,
- ivars->entry);
- if (stat((char*)CB_Get_Ptr8(ivars->fullpath), &stat_buf) != -1) {
- if (stat_buf.st_mode & S_IFDIR) { return true; }
- }
- return false;
+ DECREF(fullpath);
+ return retval;
}
bool
@@ -291,16 +289,15 @@ FSDH_Entry_Is_Symlink_IMP(FSDirHandle *self) {
return sys_dir_entry->d_type == DT_LNK ? true : false;
#else
{
+ bool retval = false;
struct stat stat_buf;
- if (!ivars->fullpath) {
- ivars->fullpath = CB_new(CB_Get_Size(ivars->dir) + 20);
- }
- CB_setf(ivars->fullpath, "%o%s%o", ivars->dir, CHY_DIR_SEP,
- ivars->entry);
- if (stat((char*)CB_Get_Ptr8(ivars->fullpath), &stat_buf) != -1) {
- if (stat_buf.st_mode & S_IFLNK) { return true; }
+ CharBuf *fullpath = CB_newf("%o%s%o", ivars->dir, CHY_DIR_SEP,
+ ivars->entry);
+ if (stat((char*)CB_Get_Ptr8(fullpath), &stat_buf) != -1) {
+ if (stat_buf.st_mode & S_IFLNK) { retval = true; }
}
- return false;
+ DECREF(fullpath);
+ return retval;
}
#endif // CHY_HAS_DIRENT_D_TYPE
}
@@ -308,10 +305,6 @@ FSDH_Entry_Is_Symlink_IMP(FSDirHandle *self) {
bool
FSDH_Close_IMP(FSDirHandle *self) {
FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
- if (ivars->fullpath) {
- CB_Dec_RefCount(ivars->fullpath);
- ivars->fullpath = NULL;
- }
if (ivars->sys_dirhandle) {
DIR *sys_dirhandle = (DIR*)ivars->sys_dirhandle;
ivars->sys_dirhandle = NULL;
http://git-wip-us.apache.org/repos/asf/lucy/blob/5169be5e/core/Lucy/Store/FSDirHandle.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSDirHandle.cfh b/core/Lucy/Store/FSDirHandle.cfh
index 88700ea..0d39341 100644
--- a/core/Lucy/Store/FSDirHandle.cfh
+++ b/core/Lucy/Store/FSDirHandle.cfh
@@ -23,7 +23,6 @@ class Lucy::Store::FSDirHandle cnick FSDH
void *sys_dirhandle;
void *sys_dir_entry;
- CharBuf *fullpath;
Err *saved_error;
bool delayed_iter;