Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2350)

Unified Diff: chrome/installer/mini_installer/mini_installer.cc

Issue 294943005: Simpler memset, avoids ICE on VS2013 Update2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now actually compiles Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/mini_installer/mini_installer.cc
diff --git a/chrome/installer/mini_installer/mini_installer.cc b/chrome/installer/mini_installer/mini_installer.cc
index 28a8057627e67353dc4fb8d737337f467ea22a56..25b0c80413049d6618a1e153e5cb0a0460fc4ced 100644
--- a/chrome/installer/mini_installer/mini_installer.cc
+++ b/chrome/installer/mini_installer/mini_installer.cc
@@ -834,29 +834,11 @@ int MainEntryPoint() {
extern "C" {
#pragma function(memset)
void* memset(void* dest, int c, size_t count) {
- // Simplistic 32-bit memset C implementation which assumes properly aligned
- // memory; performance hit on memory that isn't properly aligned, but still
- // better overall then a 8-bit implementation.
- size_t adjcount = count >> 2;
- UINT32 fill = (c << 24 | c << 16 | c << 8 | c);
- UINT32* dest32 = reinterpret_cast<UINT32*>(dest);
- UINT8* dest8 = reinterpret_cast<UINT8*>(dest);
-
- // Take care of the ending 0-3 bytes (binary 11 = 3). The lack of breaks is
- // deliberate; it falls through for each byte. Think of it a simplified for
- // loop.
- switch (count - (adjcount << 2)) {
- case 3:
- dest8[count - 3] = c;
- case 2:
- dest8[count - 2] = c;
- case 1:
- dest8[count - 1] = c;
+ void* start = dest;
+ while (count--) {
+ *reinterpret_cast<char*>(dest) = static_cast<char>(c);
+ dest = reinterpret_cast<char*>(dest) + 1;
}
-
- while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time
- *(dest32++) = fill;
-
- return dest;
+ return start;
}
} // extern "C"
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698