forked from enlightenment/efl
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
This commit is contained in:
parent
fb26be4f1b
commit
e619f29e6e
|
@ -356,6 +356,7 @@ cb_introspect(const EDBus_Service_Interface *_iface, const EDBus_Message *messag
|
||||||
Eina_Iterator *iterator;
|
Eina_Iterator *iterator;
|
||||||
EDBus_Service_Interface *iface;
|
EDBus_Service_Interface *iface;
|
||||||
EDBus_Service_Object *child;
|
EDBus_Service_Object *child;
|
||||||
|
size_t baselen;
|
||||||
|
|
||||||
if (obj->introspection_data)
|
if (obj->introspection_data)
|
||||||
eina_strbuf_reset(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);
|
_introspect_append_interface(obj->introspection_data, iface);
|
||||||
eina_iterator_free(iterator);
|
eina_iterator_free(iterator);
|
||||||
|
|
||||||
|
baselen = strlen(obj->path);
|
||||||
|
/* account for the last '/' */
|
||||||
|
if (baselen != 1)
|
||||||
|
baselen++;
|
||||||
|
|
||||||
EINA_INLIST_FOREACH(obj->children, child)
|
EINA_INLIST_FOREACH(obj->children, child)
|
||||||
{
|
eina_strbuf_append_printf(obj->introspection_data,
|
||||||
const char *subpath;
|
"<node name=\"%s\" />",
|
||||||
if (strlen(obj->path) == 1)
|
child->path + baselen);
|
||||||
subpath = child->path+strlen(obj->path);
|
|
||||||
else
|
|
||||||
subpath = child->path+strlen(obj->path)+1;
|
|
||||||
eina_strbuf_append_printf(obj->introspection_data, "<node name=\"%s\" />", subpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
eina_strbuf_append(obj->introspection_data, "</node>");
|
eina_strbuf_append(obj->introspection_data, "</node>");
|
||||||
obj->introspection_dirty = EINA_FALSE;
|
obj->introspection_dirty = EINA_FALSE;
|
||||||
|
|
Loading…
Reference in New Issue