Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

MSVC08 & code optimizing

Featured Replies

Posted

hi,

i am writing a function in c++ (msvc2008 pro), which has to be "portable" (ie. no calls to other functions or APIs) and fast.

At one point i am using something like

    while(tlen++ < total)
*str++ = leChar;

which works fine, but msvc choses to "optimize" it to a crt-memset call. :/

I generally noticed msvc is very keen on replacing code with crt calls to memset, even my custom memset-function, which uses an inlined REPMOV (and serves the sole purpose of making me independant from the crt...).

Is there anyway i can turn off this specific optimization feature?

I tried all sorts of linker switches; none of which worked properly.

look here:
/>http://www.benshoof.org/blog/minicrt/

you can further optimize the minicrt code with inline assembly and stuff....

  • Author

thanks, i am aware of minicrt, using it in quiet some projects.

However, in this case i make extensive use of advanced crt features, so that`s not an option. I also doubt it would solve the problem...? smile.png

anyways, the easiest solution is

while(tlen++ < total)
{
_asm{NOP}
*str++ = leChar;
}

which effectively prevents the memset optimization.

I still dont see how memset is an optimization, though.

It takes more space and is slower.

Edited by deepzero

I had some kind of workaround back then. Something like outsourcing the code in question (in your case the loop) into a __forceinline function with #pragma optimize("", off) and on around it, respectively.

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.