Less CPU usage in C++: declaring as unsigned int or not?
What requires the most CPU: int foo = 3; or typecasting it to an unsigned int? unsigned int foo = 3; ...
What requires the most CPU: int foo = 3; or typecasting it to an unsigned int? unsigned int foo = 3; ...
I am using free to free the memory allocated for a bunch of temporary arrays in a recursive function. I would post the code but it is pretty long. When I comment out these free() calls, the program runs in less than a second. However, when I am using them, the programs takes about 20 seconds to run. Why is this happening, and how can it ...
I'm considering opening up a project to create an i-phone virtual machine for android 2.0 (read motorola droid) before i do so i have some questions: Does one already exist that i just missed? Can the the Droid's Arm Cortex A8 down-clocked to 550MHz (thanks wikipedia) handle an I-Phone abstraction layer? Performance wise the best thing...
Hello, I'm working on a video game witch require high performance so I'm trying to setup a good memory strategy or a specific part of the game, the part that is the game "model", the game representation. I have an object containing a whole game representation, with different managers inside to keep the representation consistent, followi...
Hi I'm having the following class hierarchy: class IStorage { [...] } Q_DECLARE_INTERFACE(IStorage, "ch.gorrion.smssender.IStorage/1.0") class ISQLiteStorage: public IStorage { Q_INTERFACES(IStorage) [...] } Q_DECLARE_INTERFACE(ISQLiteStorage, "ch.gorrion.smssender.ISQLiteStorage/1.0") class DASQLiteStorage: public Q...
So, the idea was a write a recursive function that compares two strings to see if string 'prefix' is contained in string 'other', without using any standard string functions, and using pointer arithmetic. below is what i came up with. i think it works, but was curious - how elegant is this, scale 1-10, any obvious funky moves you would h...
In MSVC++, there's a function strcmpi for case-insensitive C-string comparisons. When you try and use it, it goes, This POSIX function is deprecated beginning in Visual C++ 2005. Use the ISO C++ conformant _stricmp instead. What I don't see is why does ISO not want MSVC++ to use strcmpi, and why is _stricmp the preferred way, and w...
Hi! I'm working on a little rigidbody simulation. I use the Irrlicht engine for display and openMesh to work with the meshes. Now I profiled my app using VerySleepy and noticed that most of the time is spent within the following functions (exclusive the time spent in subfunctions): RtlCompareMemoryUlong 30% within module "ntdll" sou...
I'm writing a small App in which i read some text from to console, which is then stored in a classic char* string. As it happens i need to pass it to an lib which only takes UTF-8 encoded Strings. Since the Windows console uses the local Encoding, i need to convert from local encoding to UTF-8. If i'm not mistaken i could use MultiByteTo...
int i,j; std::string s; std::cin>>i>>j>>s>>s>>i; std::cout<<i<<" "<<j<<" "<<s<<" "<<i; Question Referring to the sample code above, what's the displayed output if the input string given is: "5 10 Sample Word 15 20"? The answer is 15 10 Word 15 I have the question is what's the underline policy for cin to over write the existing ...
I tried to find a related question but all previous questions are about profilers for native c++ in windows. I googled a while and learned about gprof, but the output of gprof actually contained lot of obscure internal functions. Is there a good opensource c++ profiler with good documentation? ...
Coming from Java background, I find C++'s enums very lame. I wanted to know how to write Java-like enums (the ones in which the enum values are objects, and can have attributes and methods) in C++. As an example, translate the following Java code (a part of it, sufficient to demonstrate the technique) to C++ : public enum Planet { ...
Hello, I recently stumbled upon this page. And I was particularly interested about the section which dealt with Direct Parameter Access. I was just wondering if there is any way to execute just one of the functions depending on the value of n in the following line: printf("%n$p", func1, func2, func3 .. funcN); where func1,.. have si...
i created a map. i want to print the index of the key to a file using the itr in the map. this is what i mean: map <string,int> VendorList; VendorList[abc] = 0; VendorList[mazda] = 111; VendorList[ford] = 222; VendorList[zoo] = 444; map <string,int>::iterator itr=VendorList.find("ford"); fstream textfile; textfile << itr; if i put i...
hi everyone. i have a *.exe project that was written in one solution under vs2005 and i have aDll file that the *.exe project is using. the problem is that the dll was written in adiffrent solution and when i try to make attach to the *.exe file (after i run it) from the dll solution in order to debug the dll , i get no symbols are load...
Has anyone seen any numbers / analysis on whether or not use of the C / C++ restrict keyword in gcc / g++ actual provides any significant performance boost in reality ( and not just in theory )? I've read various articles recommending / disparaging it's use, but I haven't ran across any real numbers practically demonstrating either side...
I occasionally run into this type of syntax when looking through open source code and was wondering what it's for, or what it's even called for that matter. I have crawled the internet many a times before but simple contrived examples never had it nor explained it. It looks like this class SomeIdentifier ClassName { ... } My quest...
I have some .gz compressed files which is around 5-7gig uncompressed. These are flatfiles. I've written a program that takes a uncompressed file, and reads it line per line, which works perfectly. Now I want to be able to open the compressed files inmemory and run my little program. I've looked into zlib but I can't find a good soluti...
What is the simpliest way to use a C++ header file in a vb.net application? I need to access an API defiend via the header file for a custom VB.NET windows app. ...
Server creates new thread in a threadpool. This thread reads some stuff into buffer and so on and after that, some code executes. I'd want to secure myself by changing permission of thread to lower, before this code which could be unsafe (or it's behavior could be changed ... by hacking and so on...) I am going (ha... but have nearly no...