![]() |
A possible code rewrite for the Loader load library method - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: A possible code rewrite for the Loader load library method (/showthread.php?tid=38691) |
A possible code rewrite for the Loader load library method - El Forum - 02-15-2011 [eluser]Basketcasesoftware[/eluser] Going off a suggestion by Phil Sturgeon in the "CodeIgniter Engineers" thread. Lots of work here (mostly because I tried to comment the hell out of it!) Kudos? Criticisms? Flames? Suggestions? Condolences? Fire away! ... Too big for the code block feature. Attaching as a file. Ouch! If this forum doesn't stop being a pain in the proverbial about the attachment anyways. Edit: Oh, by the way, I posted this without my usual rigorous testing. After hours of coding it I figured it needed fresher eyes and minds to spot basic typos and other minor bugs. I tried carefully proofing it as I went, but as I got more tired I was more likely to make mistakes. This is coming from a guy who at his peak years ago wrote 300+ debugged, every-line-commented, 8050 assembler code an hour... by hand. (shameless brag) Edit: Patched the attached file for the one typo in the entire 14k file. 13 downloads and no one has commented on that error message yet. Or even asked where or how to install it. Strange. Update: A substantially revised version is nearly complete. I just want to finish adequately commenting and testing it. Ok. Uploading the latest version. Seems to work right. I got lazy about the comments but I'll fix that later. Will profile the run times later. The functionality has been tweaked a little. It now will use every member of the third argument if it's an array of strings. (if it's an array of something other than strings you are on your own. %-P) A possible code rewrite for the Loader load library method - El Forum - 02-15-2011 [eluser]Jaketoolson[/eluser] My head just exploded! I need to re-look at this tomorrow but it looks great. A possible code rewrite for the Loader load library method - El Forum - 02-16-2011 [eluser]Basketcasesoftware[/eluser] I haven't even had a chance to test it yet. I imagine there might be a typo or two there. Usually is the case. A possible code rewrite for the Loader load library method - El Forum - 02-16-2011 [eluser]Basketcasesoftware[/eluser] Ooh! My first bug now that I'm actually testing the code. ![]() Quote:Parse error: syntax error, unexpected T_LOGICAL_AND in C:\xampp\htdocs\installertest\system\core\Loader.php on line 120 Edit: Extra parenthesis. Was: Code: if ( ! is_null($params)) AND ! is_array($params)) Code: if ( ! is_null($params) AND ! is_array($params)) Edit: And she's a-runnin'! :coolsmile: A possible code rewrite for the Loader load library method - El Forum - 02-16-2011 [eluser]Basketcasesoftware[/eluser] And she seems to be adding about 0.00165 seconds to the average run time of the test greeting against a clean install. I'll look for speed optimizations later unless someone else finds 'em for me. Oh, that was just 10 refreshes of data after 10 refreshes to try to get stable results. Never got them. A possible code rewrite for the Loader load library method - El Forum - 02-16-2011 [eluser]Basketcasesoftware[/eluser] Hmm. 5 more downloads since I fixed the bug and I haven't even updated the original file I posted with the patch. I'll be nice and try to patch the bug in the attachment. A possible code rewrite for the Loader load library method - El Forum - 02-16-2011 [eluser]Basketcasesoftware[/eluser] Already working on a rewrite for speed. Watch this space. I'll be providing three links. One to the suggested code, another with the code in the core file, and the last with a full working CI build with everything already put together for you. But it's 5am here right now and I need my sleep. A possible code rewrite for the Loader load library method - El Forum - 02-16-2011 [eluser]Basketcasesoftware[/eluser] Just a note. I've been working and comparing to 1.7 code at the same time and I think I let something creep in from that. Just an exit function call. That might be part of the slow up. Definitely not needed. Still haven't gone to sleep. Thinking about a complete rewrite of this entire core class based on some comments by Phil Sturgeon and others in the "CodeIgniter Engineers" thread. Seeing if certain 'upgrade to PHP 5.0' goals can be achieved without breaking existing code. __get(), __set(). Create private versions of existing functions that were supposed to be private and providing public wrappers for the legacy stuff is where I'm thinking of heading. Try to see if things can use more commenting (it's pretty good already though). A possible code rewrite for the Loader load library method - El Forum - 02-16-2011 [eluser]Jaketoolson[/eluser] I am impressed with your 'break-down' into cases, showing the many different combination's. I'm re-reading it now. Is the .txt file current? A possible code rewrite for the Loader load library method - El Forum - 02-16-2011 [eluser]Basketcasesoftware[/eluser] At the moment. It's fully functional as far as I've tested it. I'm about to do a rewrite for speed. Just replace your existing method in your Loader core class. There is an exit function that can be deleted. I was bouncing between versions and that managed to slip through the cracks. It's a legacy item from 1.7. so you can safely delete the line at the end Code: $this->_ci_assign_to_models(); |