Friday, July 30, 2010

KrzYoptimizer v1.15-pre #build 15

[Update 1.08.2010, 1:37AM GMT+1]
Adding files in selected directory is now possible. Fixed uncompressed file size detection while reading GZ archive.

This time more time passed ;P
I was busy with my rl work - was developing some program to help myself get some phone lines comparison (yea mainly I'm in charge of telephone lines and network connections at work. There are also computers used to sell tickets, but it's new thing that I got almost year ago.)
Anyway let's follow topic, This version mainly speed up Array reogranising when deleting items from list. What does that mean to You anyway? Let's put it simple. In older versions (1.12-) deleting items from list was quite fast, but following version 1.13 it slowed down. You may have noticed me mentioning in previous posts that 2x 2 dimensional arrays were added to prevent work corruption on Item List corruption (like that's going to happen but anyway) and speed up program a bit. You won't probably notice that it's faster bacause nowadays computers are fast enough to GET_ITEM from list almost as fast as from 2-dimensional array. Said so, It's still better to use a variable that belongs to program itself than trusting some other window (yea, listview is a window, button is also a window, every control in windows is a window).This version includes more logic into deleting items from array. Previously I was lazy to program it so it worked like this: You deleted items from list, it wiped data from corresponding array, (it checked if array number is empty and moved data one array up)x repeat number of items deleted. WOW! That's like doing uneccessary work, especially when most users select items by having SHIFT key pressed, not like everyone does CTRL or SHIFT+CTRL selection. New algorithm is based on simple selection range detector. While it deletes items from list it counts how many items were deleted consequently (You select items: 5-10, then it starts counting items from 10th to 5th) and runs function that reorganises array by moving it by number of items selected, up, for every selection range. This picture may show it better:

If You press delete now, programs will start checking all filles if they are selected (from the end of list to the beginning) as it did in previous versions. Note that there are around 15000 items but it works quite fast ;). When it goes up to 14th item it starts counting, so there goes 1 for 14th, 2 for 13th and then program notices 12th is not selected so it lunches array reorganising that moves data by 2 places up again from the end to the beginning of list, 15000=>14998 and so on. Next it continues searching for next selections. There is 11th, 10th and 9th item selected so it counts to 3 and runs array reorganising again. It may be kind of waste to run it everytime on selection range but it's still better than running it on each item, especially that You normally don't select items like on this screenshot. Better would be to (by looking at the example): detect that 14th number is last selected item (since it scans list from end to the beginning anyway) and then just move item 6 to 0, 8 to 1, 12 to 2 and detected the space between 2 and 15 and run array rearranging or something similar. In other words do some small reorganising in small area first then just move everything down by total number of selections. I'll most likely program it later ;)

That's it for this version:




rokko said...

Another problem. Once again I have "Run-time error "13" Type mismatch"
I can't add any PNG files (File => ADD PNG/JPG Files). Older versions works fine.

Mr_KrzYch00 said...

Yea, I was changing something in the file opening to add directory support late yesterday (as you may have noticed there is #build 9 topic and the one to download is #build 10). I will fix it in #build 11 soon...

Mr_KrzYch00 said...

Should be fixed now, It was rewritten a bit because I lost a part of old code. I think this one is a bit faster (if is outside of loop so it checks something once instead of [number_of_files_added] times). As far as I tested it works.