Showing results for Code - The Old New Thing

May 16, 2005
Post comments count0
Post likes count0

Loading the dictionary, part 4: Character conversion redux

Raymond Chen
Raymond Chen

Getting rid of was a big help, but 480ms is still not quite peppy enough. You need to respond to user actions within a tenth of a second for thing to seem responsive. Profiling the latest endeavor reveals that 40% of our CPU time is spent in . Some debugging reveals that ultimately calls but uses it to convert only one or two characters at ...

Code
May 13, 2005
Post comments count0
Post likes count0

Loading the dictionary, part 3: Breaking the text into lines

Raymond Chen
Raymond Chen

Even after moving the character conversion out of the function, profiling reveals that is still taking nearly 50% of our CPU. The fastest code is code that isn't there, so let's get rid of altogether. Oh wait, we still need to break the file into lines. But maybe we can break the file into lines faster than did. This very simple class baby...

Code
May 11, 2005
Post comments count0
Post likes count0

Loading the dictionary, part 2: Character conversion

Raymond Chen
Raymond Chen

When you want to optimize a program, you first need to know where the time is being spent. There's no point optimizing a function that isn't actually responsible for your poor performance. For example, if a particular function is responsible for 2% of your CPU time, then even if you optimized it down to infinite speed, your program would spee...

Code
May 10, 2005
Post comments count0
Post likes count0

Loading the dictionary, part 1: Starting point

Raymond Chen
Raymond Chen

The first thing we'll need to do in our little dictionary program is to load the dictionary into memory. The format of the dictionary file is as a plain text file, each line of which is of the form Since it was the Big5 dictionary we downloaded, the Chinese characters are in Big5 format, known to Windows as code page 950. Our program will be U...

Code
May 9, 2005
Post comments count0
Post likes count0

Developing a Chinese/English dictionary: Introduction

Raymond Chen
Raymond Chen

The other day, one of my colleagues mentioned that his English name "Ben" means "stupid" in Chinese: 笨/bèn/ㄅㄣˋ. (His wife is Chinese; that's why he knows this in the first place.) Knowing that the Chinese language is rich in homophones, I fired up my Chinese/English dictionary program to see if we could find anythin...

Code
May 6, 2005
Post comments count0
Post likes count0

How to query properties of the taskbar

Raymond Chen
Raymond Chen

Occasionally, people want to query properties of the taskbar. I don't quite understand why; you should just get on with your life and let the taskbar get on with its life. After all, there might not even be a taskbar, as we discussed last time. But if you really want to know (perhaps you're collecting usability data), here's how: This little...

Code
May 5, 2005
Post comments count0
Post likes count1

How do I cover the taskbar with a fullscreen window?

Raymond Chen
Raymond Chen

For some reason, people think too hard. If you want to create a fullscreen window that covers the taskbar, just create a fullscreen window and the taskbar will automatically get out of the way. Don't go around hunting for the taskbar and poking it; let it do its thing. As always, start with the scratch program and add the following: Note th...

Code
Apr 29, 2005
Post comments count0
Post likes count0

Building a dialog template at run-time

Raymond Chen
Raymond Chen

We've spent quite a bit of time over the past year learning about dialog templates and the dialog manager. Now we're going to put the pieces together to do something interesting: Building a dialog template on the fly. What we're going to write is an extremely lame version of the function. Why bother writing a bad version of something that Wind...

Code