Jump to content
  • Advertisement
Sign in to follow this  
TooLSHeD

Large executables using Boost.Xpressive.

This topic is 2975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

I'm reading in a .md5mesh file and populating a model object. I'm using Boost.Xpressive and it's working fine, except it generates a large executable. This is the code for a test app.

#include <iostream>
#include <boost/xpressive/xpressive.hpp>

using namespace boost::xpressive;

int main()
{
char const *str = " \"origin\" -1 ( 0.4811630249 -0.0000028610 0.0000000000 ) ( -0.7071067810 0.0000000000 0.0000000000 ) //";

mark_tag s1(1), s2(2), s3(3), s4(4);

cregex values = +_s >> '"' >>(s1 = (+_w)) >> '"' >> +_s >> (s2 = (optional('-') >> +_d)) >> _s >> '(' >>
_s >> (s3 = (optional('-') >> +_d >> optional('.') >> +_d)) >>
_s >> (s4 = (optional('-') >> +_d >> optional('.') >> +_d)) >> _s;

cmatch what;

if (regex_search(str, what, values))
{
std::cout << what[s1] << std::endl;
std::cout << what[s2] << std::endl;
std::cout << what[s3] << std::endl;
std::cout << what[s4] << std::endl;
}

return 0;
}




I'm developing in Ubuntu. The executable size is already 8.16 MB and it seems to double every time I extract another value. Is this normal?

Does anyone perhaps know of a better way?

Thanks

[Edited by - TooLSHeD on August 26, 2010 9:26:23 AM]

Share this post


Link to post
Share on other sites
Advertisement
So, it would seem that you are using it for simple regexes. There are a couple libraries now that do what you are doing, most notably boost::spirit, although it could be a little more complex than you really need.

The first thing to do is make sure that debugging information is disabled. If you are in debug mode thats probably the source of most of the cruft.

The second thing to do is make sure you aren't linking with anything you don't need. Extra linked libs can kill your exe size.

The third thing to do is asses: Is what you are doing complex enough that a one-shot solution not using boost would be harder? If you aren't willing to deal with the overhead, then a lightweight custom function you write will be a lot smaller, faster, and meet your requirements better.

Share this post


Link to post
Share on other sites
Hi thanks

I wasn't linking to any libraries and compiling other programs in debug mode doesn't produce executables close to that size.

I get what you are saying, I've kind of moved on to tokenizing a line at a time and looking at what delimiters were in front and after the value. So I'm writing my own function, thanks. I wasn't too concerned with the overhead, it just seemed extreme to have a little model animating demo waist so much space on just loading the file.

Cheers

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!