The cost of using objects rather than plain C variables

2013-07-07 Thread Vincent Habchi
Hi everybody, the tiny iOS app I work on currently begins by decoding 3D data in the form of a TIN: vertices, normals then triangles. There are about 200 000 of the two formers, and 400 000 of the latters (needless to say, at a later stage, I am going to improve speed by using some kind of

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread T.J. Usiyan
The short answer is yes the overhead of an object versus a primitive value is huge. The longer answer is that however tiny you think the difference might be, you need to multiply it by somewhere between 200,000 and 600,000 to really get a sense for the difference in context. For the same reasons

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Ken Thomases
On Jul 7, 2013, at 1:06 AM, Vincent Habchi wrote: At first, the TIN file didn’t include the exact number of vertices/normals/triangles, so I had to decode the whole file in order to know how large a buffer I should allocate to store each of the three data types. Meanwhile I did record the

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Quincey Morris
On Jul 6, 2013, at 23:06 , Vincent Habchi vi...@macports.org wrote: instead of [myMutableArray add:[[NSString stringFromCString:… encoding:…] componentsSeparatedBy:@, ]], I just wrote: sscanf (myLine, %f, %f, %f, t [0], t [1], t [2]) How come I get such a large discrepancy in memory usage

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Vincent Habchi
Hi! Thanks to all for your quick and kind answers. You're comparing apples to oranges. That’s a nice way of putting it! You were storing strings for each numeric value, now you're storing doubles. Actually just floats, in order to save space. You could have tried NSNumber objects instead

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Vincent Habchi
Quincey, Each NSString has at least 4 bytes of overhead (the 'isa' pointer); each character is UTF-16; each object is a multiple of 16 bytes. Your values may not fit in the remaining 12 bytes of the smallest object (an input format something like '0.xe-nn', which isn't an unlikely format,

NSTextField / NSSecureTextField toggl

2013-07-07 Thread Michael Starke
Hello List, I'm somewhat heading down a road of pain with this. Maybe I approach the problem from the wrong angle, so I wanted to ask for advice. My goal is to have a NSTextField that can be toggled to display a Password in clear or bulleted format. Sort of NSTextField - NSSecureTextField I'm

Re: NSTextField / NSSecureTextField toggl

2013-07-07 Thread Michael Starke
Well, turns out you can use NSString's: - (void)enumerateSubstringsInRange:options:usingBlock: Using the NSStringEnumerationByComposedCharacterSequences option, you get the actual character count. But that's just a little bit nearer to the solution, as I'm guessing I need to intervene earlier

Re: NSTextField / NSSecureTextField toggl

2013-07-07 Thread Mike Abdullah
I reckon this code of mine is what you want: https://github.com/karelia/SecurityInterface/blob/master/README.md Mike. Sent from my iPhone On 7 Jul 2013, at 13:46, Michael Starke michael.sta...@hicknhack-software.com wrote: Hello List, I'm somewhat heading down a road of pain with this.

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread dangerwillrobinsondanger
Sent from my iPhone On 2013/07/07, at 16:33, Vincent Habchi vi...@macports.org wrote: Hi! Thanks to all for your quick and kind answers. You're comparing apples to oranges. That’s a nice way of putting it! You were storing strings for each numeric value, now you're storing

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Scott Ribe
On Jul 7, 2013, at 1:33 AM, Vincent Habchi wrote: Is there any hope in the future to be able to store simple types like int or floats in NSArrays? Why? What's wrong with a simple array? (Or, I would argue, though it's not a popular strategy, what's wrong with std::vector?) Now if you

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Vincent Habchi
Hi! You’re right to point that CFtypes exist: I often overlook these and that’s stupid of me. Why? What's wrong with a simple array? Nothing. Well, at first, I was looking for a self expanding array, given that I didn’t know the size beforehand. (Or, I would argue, though it's not a

Re: NSTextField / NSSecureTextField toggl

2013-07-07 Thread Jens Alfke
On Jul 7, 2013, at 5:46 AM, Michael Starke michael.sta...@hicknhack-software.com wrote: I'm somewhat heading down a road of pain with this. Maybe I approach the problem from the wrong angle, so I wanted to ask for advice. My goal is to have a NSTextField that can be toggled to display a

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Scott Ribe
On Jul 7, 2013, at 10:38 AM, Vincent Habchi wrote: Oh, just that since I moved from plain BSD/Qt3 to MacOS/Cocoa, I swore not to write any line of C++ ever again. But that’s just a personal commitment ;) If Qt is the majority of your experience with C++, then I understand wanting to avoid

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Scott Ribe
And while we're on the subject of speed, you're already dealing with threads, you're already prefixing the values with a count, if you get to a format where values in the input file are fixed-length, then you can find sections 2 3 without reading 1 2, so you could load the sections in

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Jens Alfke
On Jul 7, 2013, at 1:08 AM, Vincent Habchi vi...@macports.org wrote: My initial reasoning was very (too) simple: I have a 20 MB file made up of strings, if I store those strings in objects, even with a small overhead, it should not top 30 or 40 MB. It turned out I was plainly wrong, at

Re: The cost of using objects rather than plain C variables

2013-07-07 Thread Frederick Bartram
Is there any hope in the future to be able to store simple types like int or floats in NSArrays? Have you tried using NSData to store C-arrays? *- * Frederick Bartram * PGP key id: 0x63fa758 keyserver: http://keyserver.pgp.com */ smime.p7s

pathForResource:ofType: iOS bug?

2013-07-07 Thread Jeff Smith
Hi, pathForResource:ofType: is returning a path string with 4 garbage characters added to the end of the string. To make sure it wasn't my program causing the problem I created a new iOS project to try it out and it does it too. Empty Application Devices - Universal No - Use Core Data No

Re: pathForResource:ofType: iOS bug?

2013-07-07 Thread Stephen J. Butler
How are you examining the return value? Show us that code too, please. On Sun, Jul 7, 2013 at 7:34 PM, Jeff Smith jeff...@aol.com wrote: Hi, pathForResource:ofType: is returning a path string with 4 garbage characters added to the end of the string. To make sure it wasn't my program

Re: pathForResource:ofType: iOS bug?

2013-07-07 Thread Jeff Smith
Whoops! It looks like it was my program after all. I quit Xcode and threw out all of the derived data and tried it again. Now it's working correctly in the test program. Sorry about that... ___ Cocoa-dev mailing list