qwert Posted September 14, 2014 Share Posted September 14, 2014 I’ve been using the Au3Stripper with great success. But as I bring individual scripts to completion, I’ve noticed what appears to be some excess baggage on board the produced sources. For example: Global Const $__WINVER = __WINVER() Func __WINVER() Local $tOSVI = DllStructCreate($tagOSVERSIONINFO) DllStructSetData($tOSVI, 1, DllStructGetSize($tOSVI)) Local $aRet = DllCall('kernel32.dll', 'bool', 'GetVersionExW', 'struct*', $tOSVI) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) Return BitOR(BitShift(DllStructGetData($tOSVI, 2), -8), DllStructGetData($tOSVI, 3)) EndFunc . An SciTE search of the resulting stripped source shows that $__WINVER isn’t referenced. And I’ve found several other constants that also aren’t referenced. For my finished “production” scripts, I’d like to remove every unused element. So my question is this: Is my best approach to just take the stripped version as a "pre-compile candidate”, then manually tweak it to the minimum—and then save it as my production source before a final compile? Or, is there an easier way to reach the minimum code? BTW, I intend to eventually replace constants with their literal values. But that step needs to be taken carefully ... and I don’t want to do it too soon. That leaves UDFs and and Au3Stripper-determined "defaults" as the elements to focus on. Thanks in advance for any help. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 14, 2014 Share Posted September 14, 2014 You could always write your code so that there aren't any unreferenced variables yourself and not rely on someone else to fix your mistakes for you. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Developers Jos Posted September 14, 2014 Developers Share Posted September 14, 2014 How would au3striper be able to determine that the execution of __winver() isn't essential dispite the fact that the receiving variable isn't used? So i am only stripping variables that have a constant or literal sting on the right side of the =. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
qwert Posted September 14, 2014 Author Share Posted September 14, 2014 @Jos, That helps. It explains sequences like this, where none of the six constants are referenced ... by my code or any called UDFs, that is: Global Const $KF_EXTENDED = 0x0100 Global Const $KF_ALTDOWN = 0x2000 Global Const $KF_UP = 0x8000 Global Const $LLKHF_EXTENDED = BitShift($KF_EXTENDED, 8) Global Const $LLKHF_ALTDOWN = BitShift($KF_ALTDOWN, 8) Global Const $LLKHF_UP = BitShift($KF_UP, 8) . I’ll have to think about the __winver() case ... and also about BrewManNH’s comment. To me, this isn’t about mistakes and fixes, just optimization and how to reasonably achieve it. Thanks for your response. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 14, 2014 Developers Share Posted September 14, 2014 Understood your intentions and always appreciate when somebody puts ideas forward. The thing to realize here is that i have to be very carefull not to break the script when stripping out functions or variables. Au3stripper is not aware of script logic so only checks for variables/functions being used. In your case the variable is filled with some sort of function for which au3stripper has to assume that function could be essential for the script to remain on the safeside. I wouldn't worry too much about optimization as a few lines more or less will not matter that much in scriptsize. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now