How do Hex editors display data so quickly?
I'v created a Notepad-like application and if I load a 1MB file into the textbox, it takes about 1 minute. The Visual Studio Binary editor displays lines, Hex, and ascii versions in a开发者_如何学JAVA fraction of a second. How do they get the data into the textbox so quickly? Thanks
They only read enough of the file to display what is viewable on screen. In other words, if your UI can only display 100 bytes at a time, you only need to read 100 bytes to fill the screen. If the user scrolls the window, you have to read additional bytes to fill in the missing pieces.
I don't mean to be rude. Just hope to help and clarify: You mentioned in a reply that reading is not the problem and that the win32 guy was the problem. But I really doubt that.
First things first, disc access is monumentally slow compared to anything GUI related. Even if you set an EDIT box to contain some very large amount of text it's essentially just a memcpy and a repaint.
There is a bit of processing involved. The string must be walked through to find newlines. And if you are word-wrapping it would have to keep adding the next letter's width until you go beyond the allowed width. But both of those are pretty darn fast compared to reading from disc.
So are you really, truly sure it is a GUI speed issue and not a reading issue? Can you provide times on both? I just find it so hard to believe that the GUI is the issue here...
精彩评论