Registry Theory Question
-
Hi, I have recently been working on my first big C++ application, and it has quite a lot of persistent Registry entries. Anyway, when I want to know an app setting, I am doing AfxGetApp()->GetProfileXXX... to get the setting. My question is this: is it slower to keep calling that function or to hive off the settings and keep updating that hive if the settings are changed? Example #1: A loop 10,000 times with a Registry call each loop is probably slower than reading the value out and then looping 10,000 times. Example #2: An event fires (such as WM_CHAR) that reads a setting and uses it once before the end of the handler. Is this slower than having the external hive? Input, ideas and peep's programming practices in this field greatly appreciated. Thanks in advance, Si
-
Hi, I have recently been working on my first big C++ application, and it has quite a lot of persistent Registry entries. Anyway, when I want to know an app setting, I am doing AfxGetApp()->GetProfileXXX... to get the setting. My question is this: is it slower to keep calling that function or to hive off the settings and keep updating that hive if the settings are changed? Example #1: A loop 10,000 times with a Registry call each loop is probably slower than reading the value out and then looping 10,000 times. Example #2: An event fires (such as WM_CHAR) that reads a setting and uses it once before the end of the handler. Is this slower than having the external hive? Input, ideas and peep's programming practices in this field greatly appreciated. Thanks in advance, Si
I recommend that you read the config settings at program startup and store them somewhere instead of re-querying the registry every time you need a value.
Author of the romantic comedy Summer Love and Some more Cricket [New Win]
-
I recommend that you read the config settings at program startup and store them somewhere instead of re-querying the registry every time you need a value.
Author of the romantic comedy Summer Love and Some more Cricket [New Win]
-
This is what I thought. ;) I was just wondering whether AfxGetApp() within MFC did some smart cacheing of values. I would have thought not, but here's hoping.
It's not AfxGetApp() that's slow (trace into it and see), but doing thousands of registry calls is. The registry is a database, and access won't be lightning-quick. As Nish said, read your config into variables at startup, then save it on exit. --Mike-- Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer My really out-of-date homepage Sonork-100.19012 Acid_Helm