Re: Speeding Up libglade
- From: Andreas Volz <lists brachttal net>
- To: gtk-app-devel-list gnome org
- Subject: Re: Speeding Up libglade
- Date: Mon, 6 Apr 2009 21:03:10 +0200
Am Sun, 05 Apr 2009 16:03:54 +0200 schrieb arne:
Hello,
I want to run my application on a Embedded System with a weak CPU.
Compared to another program which I build earlier with Glade2 the
start time of my actual application is appreciable slower.
I read the Article
http://syslog.movial.fi/uploads/compiled-libglade.pdf. Does anyone
know where can I get this build of libglade or if there exist a patch?
Is there another way to speed up libglade?
Maybe you could try to link your glade XML file into your application.
I've done it with this script:
http://pastebin.com/f677a2f2
And run it with:
$ perl bin2hex.pl myfile.glade 1 my_glade_data > myglade.h
and then this code:
#ifdef GLADE_HEADER_COMPILE
#include "myglade.h" // this is created with bin2hex.pl
#else
#define GLADE_FILE "myfile.glade"
#endif
Glib::RefPtr<Gnome::Glade::Xml> createGlade (const Glib::ustring &root,
const Glib::ustring &domain)
{
#ifdef GLADE_HEADER_COMPILE
return Gnome::Glade::Xml::create_from_buffer(
my_glade_data, my_glade_data_size,
root, domain);
#else
return Gnome::Glade::Xml::create(
searchGladeFile (GLADE_FILE), root, domain);
#endif
}
const std::string searchGladeFile (const std::string &glade_file)
{
vector <string> name_vector;
name_vector.push_back (glade_file);
name_vector.push_back ("../" + glade_file);
name_vector.push_back ("src/" + glade_file);
// TODO: src dir variable...
name_vector.push_back (string (PACKAGE_DATA_DIR) + "/glade/" + glade_file);
return searchFile (name_vector);
}
const std::string searchFile (std::vector <std::string> &name_vector)
{
struct stat buf;
for (unsigned int i = 0; i < name_vector.size (); i++)
{
string &try_name = name_vector[i];
bool found = !(stat (try_name.c_str (), &buf));
if (found)
{
return try_name;
}
}
return "";
}
I used it to hide a glade XML in a commercial application, but maybe you
could save loading time on your embedded hardware.
regards
Andreas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]