summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-11-03 07:33:32 +0000
committerJim Meyering <jim@meyering.net>2001-11-03 07:33:32 +0000
commit93b4e4074feaacf770435aa7d71075cac9b0f7b9 (patch)
treecc91edc918aff19f021037d16ad0040f956c67f1 /src
parentf1bafaa2378ae2977fa5d5683c135bfc3b0c8417 (diff)
downloadcoreutils-93b4e4074feaacf770435aa7d71075cac9b0f7b9.tar.xz
(DEV_INO_PUSH): Avoid unnecessary copies.
(dev_ino_pop): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/ls.c b/src/ls.c
index 43f74a3a7..4c5b20a2b 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -892,14 +892,15 @@ static struct obstack subdired_obstack;
static struct obstack dev_ino_obstack;
/* Push a pair onto the device/inode stack. */
-#define DEV_INO_PUSH(Dev, Ino) \
- do \
- { \
- struct dev_ino di; \
- di.st_dev = (Dev); \
- di.st_ino = (Ino); \
- obstack_grow (&dev_ino_obstack, &di, sizeof (di)); \
- } \
+#define DEV_INO_PUSH(Dev, Ino) \
+ do \
+ { \
+ struct dev_ino *di; \
+ obstack_blank (&dev_ino_obstack, sizeof (struct dev_ino)); \
+ di = -1 + (struct dev_ino *) obstack_next_free (&dev_ino_obstack); \
+ di->st_dev = (Dev); \
+ di->st_ino = (Ino); \
+ } \
while (0)
/* Pop a dev/ino struct off the global dev_ino_obstack
@@ -907,11 +908,9 @@ static struct obstack dev_ino_obstack;
static struct dev_ino
dev_ino_pop (void)
{
- struct dev_ino di;
- assert (sizeof di <= obstack_object_size (&dev_ino_obstack));
- obstack_blank (&dev_ino_obstack, -(int) (sizeof di));
- di = *(struct dev_ino*) obstack_next_free (&dev_ino_obstack);
- return di;
+ assert (sizeof (struct dev_ino) <= obstack_object_size (&dev_ino_obstack));
+ obstack_blank (&dev_ino_obstack, -(int) (sizeof (struct dev_ino)));
+ return *(struct dev_ino*) obstack_next_free (&dev_ino_obstack);
}
#define ASSERT_MATCHING_DEV_INO(Name, Di) \