Ticket #1818 (accepted defect) — at Version 9
Refactoring no-vfs
Reported by: | metux | Owned by: | metux |
---|---|---|---|
Priority: | major | Milestone: | 4.7.4 |
Component: | mc-vfs | Version: | master |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | Votes for changeset: |
Description (last modified by andrew_b) (diff)
Building w/o VFS seems quite a bit broken now.
Refactoring it, eg. moving stuff from src/vfsdummy.h into vfs/vfs.h and get rid of some #ifdef VFS
branch:1818_refactoring_no_vfs
changeset:6c4ff4d6bb0a14627667f77c697ebdd7a0780ec9
Change History
comment:2 Changed 15 years ago by metux
- Owner set to metux
- Keywords vfs no-vfs added
- Status changed from new to accepted
- Description modified (diff)
- severity changed from no branch to on review
comment:3 Changed 15 years ago by andrew_b
- severity changed from on review to on rework
vfs/vfs.h
223 p = strdup (p); 254 #endif /* MC_VFSDUMMY_H */
Please fix that.
And use g_strdup() instead of strdup() and g_snprintf() instead of snprintf().
comment:4 Changed 15 years ago by metux
In which way is g_strdup()/g_snprint() better than strdup()/snprintf(), despite being slower ?
comment:5 Changed 15 years ago by andrew_b
Actually, in most cases (99%) that glib functions are used in MC.
comment:6 follow-up: ↓ 8 Changed 15 years ago by metux
That doesnt change the fact, that these two functions are nothing but slow wrappers, without any technical benetif it that case.
Just look at the source:
g_snprintf() calls g_vsnprintf() calls vsnprintf()
Calling snprintf() is the direct way. And a clever compiler can
optimize much more (eg. inlining statically predictable cases).
comment:8 in reply to: ↑ 6 Changed 15 years ago by andrew_b
Replying to metux:
That doesnt change the fact, that these two functions are nothing but slow wrappers,
OK, let's compare:
#include <stdio.h> #include <sys/types.h> int main (int argc, char *argv[]) { size_t i, j; char buf[32]; for (i = 0; i < 10000; i++) for (j = 0; j < 10000; j++) snprintf (buf, sizeof (buf), "%ll", i + j); return 0; } /* Result: $ time ./test-snprintf 9.50user 0.00system 0:09.51elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+114minor)pagefaults 0swaps */
#include <sys/types.h> #include <glib.h> int main (int argc, char *argv[]) { size_t i, j; char buf[32]; for (i = 0; i < 10000; i++) for (j = 0; j < 10000; j++) g_snprintf (buf, sizeof (buf), "%ll", i + j); return 0; } /* Result: $ time ./test-gsnprintf 10.14user 0.00system 0:10.15elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+137minor)pagefaults 0swaps */
Tested on Intel(R) Core(TM)2 Duo CPU E6850 @ 3.00GHz
Yes, slower by 0.6 s for 100,000,000 iterations. Is it too much for you?