[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Any c++ experts here? I have a few questions: If I know the

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 8
Thread images: 2

File: smug doggo.jpg (1MB, 3264x2448px) Image search: [Google]
smug doggo.jpg
1MB, 3264x2448px
Any c++ experts here? I have a few questions:

If I know the maximum size of a loop does it benefit me to make my loop variable I a short rather than an int? If I am consistent with such tweaks throughout my code - will I see smaller, faster code?

Additionally - I have N threads who work exclusively with HEX in the format 0x000-0xFFF, if I were to create a simple string ((threads * length) + 1) long and provide pointers to their respective positions in the string, could the threads safely use the string as a storage object without requiring mutexes etc? Is this a bad idea?

Thanks /g/!
>>
Yes but is pretty negligible. Also you drastically affect the reusability of your code.
>>
>>60287637
>not making it auto
not gonna make it
>>
Also that's a corgo not a doggo
>>
File: Screenshot_2017-05-08_23-30-04.png (60KB, 769x993px) Image search: [Google]
Screenshot_2017-05-08_23-30-04.png
60KB, 769x993px
Using shorts instead of ints will save RAM, but it may or may not be faster on your CPU. That depends on the CPU you're using. Download your CPU's Software Optimization Guides and look it up there.
>>
>>60287637
Depends on architecture famalamalia
>>
>>60287637
compile with optimizations on, profile it, look at the disassembly

Sounds bad, if nothing else it's easy to make errors. Why not have them edit separate strings, and then concat when you need the whole string for something?
>>
>>60287637
it literally does not, a 64 bit machine uses 64 bit registers and will, in most cases, still waste 64 bits storing a variable thats less than 64 bit
Thread posts: 8
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.