Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 Accessing Com Objects
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

GauravBhabu
Advanced Member

4288 Posts

Posted - 17 October 2002 :  00:11:38  Show Profile
quote:
When accessing COM objects in ASP, you should copy frequently-used object data to script variables. This will cut down on COM method calls, which are relatively expensive compared to accessing script variables. When accessing Collection and Dictionary objects, this technique also cuts down on expensive lookups.

In general, if you are going to access object data more than once, put that data into a script variable. Prime targets for this optimization are Request variables (Form and QueryString variables). For example, your site may pass around a QueryString variable called UserID. Suppose this UserID is referenced a dozen times on a particular page. Instead of calling Request("UserID") a dozen times, assign the UserID to a variable at the top of the ASP page. Then use that variable throughout the page. This will save 11 COM method calls.

As it says the calls to com objects are relatively expensive. I have been looking through each and every file and have found that some improvements can be made, if it will really improve the performance or reduce the memory usage.
Few examples:
active.asp
Current code : Two calls to Com Objects
if Request.form("cookie") = "1" then
	if strSetCookieToForum = 1 then	
		Response.Cookies(strCookieURL & "Reload").Path = strCookieURL
	end if
	Response.Cookies(strCookieURL & "Reload") = Request.Form("RefreshTime")
	Response.Cookies(strCookieURL & "Reload").expires = strForumTimeAdjust + 365
	nRefreshTime = Request.Form("RefreshTime")
end if

Can be reduced to One call

dim nRefreshTime, ArchiveLink
nRefreshTime = Request.Cookies(strCookieURL & "Reload")
if Request.form("cookie") = "1" then
 if strSetCookieToForum = 1 then	
  Response.Cookies(strCookieURL & "Reload").Path = strCookieURL
 end if
 nRefreshTime = Request.Form("RefreshTime")
 Response.Cookies(strCookieURL & "Reload") = nRefreshTime 
 Response.Cookies(strCookieURL & "Reload").expires = strForumTimeAdjust + 365
end if


topic.asp
Current code : Four/Five calls to Com Objects
if (Request.QueryString("TOPIC_ID") = "" or _
        IsNumeric(Request.QueryString("TOPIC_ID")) = False) and _
        Request.Form("Method_Type") <> "login" and _
        Request.Form("Method_Type") <> "logout" then
	Response.Redirect "default.asp"
	Response.End
else
	Topic_ID = cLng(Request.QueryString("TOPIC_ID"))
end if

Can be reduced to Two calls
Dim Topic_ID, strLoginMethod
Topic_ID = Request.QueryString("TOPIC_ID")
strLoginMethod = Request.Form("Method_Type")
if ((Topic_ID = "") or (Not IsNumeric(Topic_ID))) and _
 (strLoginMethod <> "login") and (strLoginMethod <> "logout") then
 Response.Redirect "default.asp"
 Response.End
end if 
Topic_ID = cLng(Topic_ID)
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000 Version 3.4.07