How do Hex editors display data so fast?

I'v created the application in the form of a notepad, and if I upload a 1MB file to a text field, it takes about 1 minute. The Visual Studio binary editor displays strings, hexadecimal and ascii versions in a split second. How do they get data in a text box so fast? Thanks

+4
source share
2 answers

They only read the file enough to display what can be viewed on the screen. In other words, if your user interface 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 must read additional bytes to fill in the missing fragments.

+9
source

I do not want to be rude. I just hope to help and clarify: You mentioned in the answer that reading is not a problem, and there is a problem with the win32 guy. But I really doubt it.

First, access to the disk is monumentally slow compared to something related to the graphical interface. Even if you set a certain amount of text in the EDIT field, it is essentially only memcpy and repaint.

There is a bit of processing. You need to go through the line to find new lines. And if you wrap a word, it will have to continue to add the next letter width until you go beyond the allowable width. But both of them are quite agile compared to reading from disk.

So, are you really sure that this is a GUI speed issue, not a read issue? Can you provide time for both? It’s just hard for me to believe that the GUI here is a problem ...

0
source

Source: https://habr.com/ru/post/1307940/


All Articles