From e619f29e6e176f535bc0d0487daddf7a5e00fa8c Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 12 Nov 2012 16:06:51 +0000 Subject: [PATCH] edbus: simplify and explain code No need to strlen(obj->path) twice per loop iteration. Do it only once and add a comment explaining the difference between handling "/" and "/my/path/to/obj". SVN revision: 79176 --- legacy/edbus/src/lib/edbus_service.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/legacy/edbus/src/lib/edbus_service.c b/legacy/edbus/src/lib/edbus_service.c index cf21a14ecc..109ef602d5 100644 --- a/legacy/edbus/src/lib/edbus_service.c +++ b/legacy/edbus/src/lib/edbus_service.c @@ -356,6 +356,7 @@ cb_introspect(const EDBus_Service_Interface *_iface, const EDBus_Message *messag Eina_Iterator *iterator; EDBus_Service_Interface *iface; EDBus_Service_Object *child; + size_t baselen; if (obj->introspection_data) eina_strbuf_reset(obj->introspection_data); @@ -372,15 +373,15 @@ cb_introspect(const EDBus_Service_Interface *_iface, const EDBus_Message *messag _introspect_append_interface(obj->introspection_data, iface); eina_iterator_free(iterator); + baselen = strlen(obj->path); + /* account for the last '/' */ + if (baselen != 1) + baselen++; + EINA_INLIST_FOREACH(obj->children, child) - { - const char *subpath; - if (strlen(obj->path) == 1) - subpath = child->path+strlen(obj->path); - else - subpath = child->path+strlen(obj->path)+1; - eina_strbuf_append_printf(obj->introspection_data, "", subpath); - } + eina_strbuf_append_printf(obj->introspection_data, + "", + child->path + baselen); eina_strbuf_append(obj->introspection_data, ""); obj->introspection_dirty = EINA_FALSE;