sysparams: slight optimsation for IDA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, this patch optimises the SPI_GETNONCLIENTMETRICS and 
SPI_GETICONTITLELOGFONT SystemParameters. These are loaded *continually* by 
IDA Pro. As these properties weren't cached previously, this really slowed 
everything down as it hit the disk every time.
Index: windows/sysparams.c
===================================================================
RCS file: /home/wine/wine/windows/sysparams.c,v
retrieving revision 1.56
diff -u -r1.56 sysparams.c
--- windows/sysparams.c	31 Oct 2003 04:18:55 -0000	1.56
+++ windows/sysparams.c	29 Nov 2003 14:05:23 -0000
@@ -148,6 +148,10 @@
 static BOOL keyboard_pref = TRUE;
 static BOOL screen_reader = FALSE;
 static BOOL screensaver_running = FALSE;
+static LOGFONTA iconTitleLogFont;
+static INT nonClientMetrics_MenuFontHeight;
+static CHAR nonClientMetrics_MenuFontFaceName[LF_FACESIZE];
+
 
 /***********************************************************************
  *		GetTimerResolution (USER.14)
@@ -1092,28 +1096,37 @@
 
         if (!pvParam) return FALSE;
 
-	/*
-	 * The 'default GDI fonts' seems to be returned.
-	 * If a returned font is not a correct font in your environment,
-	 * please try to fix objects/gdiobj.c at first.
-	 */
-	SYSPARAMS_GetGUIFont( &lfDefault );
-
-	GetProfileStringA( "Desktop", "IconTitleFaceName",
-			   lfDefault.lfFaceName,
-			   lpLogFont->lfFaceName, LF_FACESIZE );
-	lpLogFont->lfHeight = -GetProfileIntA( "Desktop", "IconTitleSize", 11 );
-	lpLogFont->lfWidth = 0;
-	lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
-	lpLogFont->lfWeight = FW_NORMAL;
-	lpLogFont->lfItalic = FALSE;
-	lpLogFont->lfStrikeOut = FALSE;
-	lpLogFont->lfUnderline = FALSE;
-	lpLogFont->lfCharSet = lfDefault.lfCharSet; /* at least 'charset' should not be hard-coded */
-	lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
-	lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
-	lpLogFont->lfPitchAndFamily = DEFAULT_PITCH;
-	lpLogFont->lfQuality = DEFAULT_QUALITY;
+        spi_idx = SPI_GETICONTITLELOGFONT;
+	    
+        if (!spi_loaded[spi_idx])
+        {
+	    /*
+	     * The 'default GDI fonts' seems to be returned.
+	     * If a returned font is not a correct font in your environment,
+	     * please try to fix objects/gdiobj.c at first.
+	     */
+	    SYSPARAMS_GetGUIFont( &lfDefault );
+	    
+	    GetProfileStringA( "Desktop", "IconTitleFaceName",
+			       lfDefault.lfFaceName,
+			       iconTitleLogFont.lfFaceName, LF_FACESIZE );
+	    iconTitleLogFont.lfHeight = -GetProfileIntA( "Desktop", "IconTitleSize", 11 );
+	    iconTitleLogFont.lfWidth = 0;
+	    iconTitleLogFont.lfEscapement = iconTitleLogFont.lfOrientation = 0;
+	    iconTitleLogFont.lfWeight = FW_NORMAL;
+	    iconTitleLogFont.lfItalic = FALSE;
+	    iconTitleLogFont.lfStrikeOut = FALSE;
+	    iconTitleLogFont.lfUnderline = FALSE;
+	    iconTitleLogFont.lfCharSet = lfDefault.lfCharSet; /* at least 'charset' should not be hard-coded */
+	    iconTitleLogFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
+	    iconTitleLogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+	    iconTitleLogFont.lfPitchAndFamily = DEFAULT_PITCH;
+	    iconTitleLogFont.lfQuality = DEFAULT_QUALITY;
+	    
+	    spi_loaded[spi_idx] = TRUE;
+	}
+
+        memcpy(lpLogFont, &iconTitleLogFont, sizeof(LOGFONTA));
 	break;
     }
 
@@ -1209,55 +1222,65 @@
 
         if (!pvParam) return FALSE;
 
+        spi_idx = SPI_GETNONCLIENTMETRICS;
+	
 	if (lpnm->cbSize == sizeof(NONCLIENTMETRICSA))
 	{
-	    /* clear the struct, so we have 'sane' members */
-	    memset(
-		(char *)pvParam + sizeof(lpnm->cbSize),
-		0,
-		lpnm->cbSize - sizeof(lpnm->cbSize)
-		);
-
+	    /* clear the supplied struct, so we have 'sane' members */
+	    memset((char *)pvParam + sizeof(lpnm->cbSize),
+		   0,
+		   lpnm->cbSize - sizeof(lpnm->cbSize)
+		   );
+	    
 	    /* initialize geometry entries */
 	    lpnm->iBorderWidth = 1;
 	    lpnm->iScrollWidth = GetSystemMetrics(SM_CXVSCROLL);
 	    lpnm->iScrollHeight = GetSystemMetrics(SM_CYHSCROLL);
-
+		
 	    /* size of the normal caption buttons */
 	    lpnm->iCaptionWidth = GetSystemMetrics(SM_CXSIZE);
 	    lpnm->iCaptionHeight = GetSystemMetrics(SM_CYSIZE);
-
+		
 	    /* caption font metrics */
 	    SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfCaptionFont), 0 );
 	    lpnm->lfCaptionFont.lfWeight = FW_BOLD;
-
+		
 	    /* size of the small caption buttons */
 	    lpnm->iSmCaptionWidth = GetSystemMetrics(SM_CXSMSIZE);
 	    lpnm->iSmCaptionHeight = GetSystemMetrics(SM_CYSMSIZE);
-
+	    
 	    /* small caption font metrics */
 	    SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfSmCaptionFont), 0 );
-
+	    
 	    /* menus, FIXME: names of wine.conf entries are bogus */
-
+		
 	    /* size of the menu (MDI) buttons */
 	    lpnm->iMenuWidth = GetSystemMetrics(SM_CXMENUSIZE);
 	    lpnm->iMenuHeight = GetSystemMetrics(SM_CYMENUSIZE);
-
+		
 	    /* menu font metrics */
 	    SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfMenuFont), 0 );
-	    GetProfileStringA( "Desktop", "MenuFont",
-			       (TWEAK_WineLook > WIN31_LOOK) ? lpnm->lfCaptionFont.lfFaceName : "System",
-			       lpnm->lfMenuFont.lfFaceName, LF_FACESIZE );
-	    lpnm->lfMenuFont.lfHeight = -GetProfileIntA( "Desktop", "MenuFontSize", 11 );
+	    
+	    /* we only cache the Dektop/MenuFont stuff as everything else is backed by SystemMetrics */
+	    if (!spi_loaded[spi_idx]) {
+		GetProfileStringA( "Desktop", "MenuFont",
+				   (TWEAK_WineLook > WIN31_LOOK) ? lpnm->lfCaptionFont.lfFaceName : "System",
+				   nonClientMetrics_MenuFontFaceName, LF_FACESIZE );
+		nonClientMetrics_MenuFontHeight = -GetProfileIntA( "Desktop", "MenuFontSize", 11 );
+		spi_loaded[spi_idx] = TRUE;
+	    }
+	    memcpy(lpnm->lfMenuFont.lfFaceName, nonClientMetrics_MenuFontFaceName, LF_FACESIZE);
+	    lpnm->lfMenuFont.lfHeight = nonClientMetrics_MenuFontHeight;
 	    lpnm->lfMenuFont.lfWeight = (TWEAK_WineLook > WIN31_LOOK) ? FW_NORMAL : FW_BOLD;
-
+	    
 	    /* status bar font metrics */
 	    SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0,
 				   (LPVOID)&(lpnm->lfStatusFont), 0 );
 	    /* message font metrics */
 	    SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0,
 				   (LPVOID)&(lpnm->lfMessageFont), 0 );
+	    
+	    spi_loaded[spi_idx] = TRUE;
 	}
 	else
 	{

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux