Lesson 9 of 18

Making Variable Access Faster with Typing

Duration: 1:01 Watch on YouTube (external link, opens in new tab)

Markdown version

In this lesson

Roy Osherove shows that the types of variables matter for speed: when the content is put into string variables instead of variants, FinalBuilder (external link, opens in new tab) does not have to figure out what the content is, and access to the variables is usually much faster.

Transcript

145 words

[00:02] (external link, opens in new tab) Here's another important trick that I want to show you. I want to show how we can actually make things go faster. Right now, let's look at how long it takes to iterate. And you'll see that some of the strings seems to sometimes be iterating quite slowly. The types of the variables are very important. If the types match the content, the content will go much faster. Let me just try to to show that again. You'll see that sometimes iteration takes sometimes more, sometimes less.

[00:33] (external link, opens in new tab) Let's try that again. Seems to be okay. If we put the contents into actual strings instead of variants, then FinalBuilder doesn't have to figure out what is the content, see what it fits into, etc. So, if it's a string, declare it as a string. And what you'll see is usually much faster access to the variables.