Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-14-2010, 06:54 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 3
mjokipii is on a distinguished road
Default C++ strings and stl efficiency

Hi, and thanks to the helpful posts i've been reading so far on these forums!

Do heavy processing applications, such as games, suffer significant loss on efficiency if i use standard C++ strings and STL in general?

I'm using some third party code that implements a very useful SDK. The code is very much like C although it is C++. STL has not been used anywhere in the code. I'm wondering if there's a reason for this. I know STL relies heavily on dynamic allocation of objects on the fly. Could this be problematic to the iOS for example?

I like STL very much and find it very useful and would like to use it in my iPhone code. Would that be unwise?

Thanks,

Matti Jokipii,
No Brakes Media
mjokipii is offline   Reply With Quote
Old 08-14-2010, 09:26 AM   #2 (permalink)
Maker of Games
 
Mr Jack's Avatar
 
Join Date: Nov 2009
Location: Coventry, UK
Posts: 395
Mr Jack is on a distinguished road
Default

The STL is stonkingly fast, but make sure you take the time to understand its performance characteristics with respect to what you are actually doing.

If you're worried about dynamic object allocation, write yourself a custom small object allocator.

All strings are slow, by the nature of being strings. I have no idea whether the std::string implementation is particularly slow or not, but I would suspect it's actually pretty speedy.
__________________


Visit Mr Jack Games for my blog and more about my games
Mr Jack is offline   Reply With Quote
Old 08-14-2010, 12:19 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 234
warmi is on a distinguished road
Default

Quote:
Originally Posted by mjokipii View Post
I like STL very much and find it very useful and would like to use it in my iPhone code. Would that be unwise?

Thanks,

Matti Jokipii,
No Brakes Media
I use it all the time.
Just make sure you are going smart about it like preallocating your containers ahead of time etc ...

Don't use lists or maps if you are dealing with a small number of items ( preallocated vectors will do just fine)
Alternatively you can start using things like intrusive containers (Chapter*10.*Boost.Intrusive)
warmi is offline   Reply With Quote
Old 08-15-2010, 08:22 AM   #4 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 3
mjokipii is on a distinguished road
Default

Quote:
Originally Posted by Mr Jack View Post
If you're worried about dynamic object allocation, write yourself a custom small object allocator.
Hopefully i don't deed to but this seems like a very good tip!

Quote:
Originally Posted by Mr Jack View Post
All strings are slow, by the nature of being strings. I have no idea whether the std::string implementation is particularly slow or not, but I would suspect it's actually pretty speedy.
I can live with the usual overhead as long as there are no iPhone specific problems.

Thank you very much for the quick reply and your good advice!
mjokipii is offline   Reply With Quote
Old 08-15-2010, 08:36 AM   #5 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 3
mjokipii is on a distinguished road
Default

Quote:
Originally Posted by warmi View Post
I use it all the time.
Just make sure you are going smart about it like preallocating your containers ahead of time etc ...
I'm glad to hear you're using it with success. This sounds like another good tip! I think i can allocate and request the necessary capacity pretty much at construction or immediately after.
Quote:
Originally Posted by warmi View Post
Don't use lists or maps if you are dealing with a small number of items ( preallocated vectors will do just fine)
Yes, as i said in my reply to Mr Jack, i'm not all that worried about the usual load that we get with STL. I was mostly worried about some unexpected problems that might be specific to the iPhone platform.
Quote:
Originally Posted by warmi View Post
Alternatively you can start using things like intrusive containers (Chapter*10.*Boost.Intrusive)
That looks interesting! Haven't heard of those before. The technique seems to eliminate a lot of allocations and speed things up in other ways as well. That could be a very useful tool to have in the toolbox.

Thank you very much for your advice!
mjokipii is offline   Reply With Quote
Old 08-27-2010, 08:07 AM   #6 (permalink)
Registered Member
 
Join Date: May 2010
Location: Portugal
Posts: 18
^DJ_Link^ is on a distinguished road
Default

I use stl on my engine very heavely. Lists, vectors etc.
It runs pretty fast. Worry about batching as much primitives as possible on each GLdraw and you should be fine
^DJ_Link^ is offline   Reply With Quote
Reply

Bookmarks

Tags
c++, memory, std, stl, string

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 401
11 members and 390 guests
7twenty7, ChrisYates, djohnson, Duncan C, gmarro, hussain1982, Kirkout, Retouchable, SLIC, walex, xzoonxoom
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:06 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0