C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-01-2004, 07:33 AM   #1
Super Moderator
 
Join Date: Sep 2001
Posts: 4,746
Eliminating Seperate Function in While Loop

This problem would probably have the same solution in all the "C" languages, but the code is C# so I posted here just in case there is a difference.

For my server program, I've written all the code, except for a few additional features (but the basics are there), and now I'm going through and just simplifying the code as much as possible. I've reduced a 12kb file into 39 lines of code. I could take that down even futher if I could figure out a way to do this. Right now, all the code for processing HTTP requests once they are recieved is handled by a single function, which makes separating HTTP from FTP very easy. The only problem is that in my HTTP code I have something like this:

Code:
while(mymethod() == true)
{
    // Execute all this code
}
Now mymethod() has several lines of code, so I can't really just place the statement on code in the loop, but just for the sake of having things kept in one method, I'd really like to eliminate the need to call a method outside of this one. Any ideas?
sean is offline   Reply With Quote
Old 07-01-2004, 09:23 PM   #2
Registered User
 
Draco's Avatar
 
Join Date: Apr 2002
Posts: 463
could you post some of your surrounding code to help give context?
Draco is offline   Reply With Quote
Old 07-01-2004, 11:37 PM   #3
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,680
Is there a point to this compression of the source code?
Because you seem to have gone past simplification and into obfuscation.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 07-02-2004, 01:09 AM   #4
Registered User
 
Frobozz's Avatar
 
Join Date: Dec 2002
Posts: 546
Contest perhaps? But yeah seeing additional code would make it a lot easier.
Frobozz is offline   Reply With Quote
Old 07-02-2004, 09:23 AM   #5
Super Moderator
 
Join Date: Sep 2001
Posts: 4,746
I actually figured out a way to do it this morning. It's not so much compressing the code, but removing everything unnecessary.
sean is offline   Reply With Quote
Old 07-02-2004, 10:41 AM   #6
Registered User
 
Frobozz's Avatar
 
Join Date: Dec 2002
Posts: 546
Geez. From 12kb to 39 lines is removing unnecessary code? You should go do that to SharpDevelop. Maybe it'd speed up to usable.
Frobozz is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Either my loop is bad or my function is messed up crazychile C Programming 25 11-02-2008 02:04 PM
Problem with Visual C++ Object-Oriented Programming Book. GameGenie C++ Programming 9 08-29-2005 11:21 PM
Scope And Parameter Passing djwicks C Programming 6 03-28-2005 08:26 PM
qt help Unregistered Linux Programming 1 04-20-2002 09:51 AM


All times are GMT -6. The time now is 12:04 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22