Thread: Eliminating Seperate Function in While Loop

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912

    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?

  2. #2
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    could you post some of your surrounding code to help give context?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    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.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #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.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I actually figured out a way to do it this morning. It's not so much compressing the code, but removing everything unnecessary.

  6. #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.

Popular pages Recent additions subscribe to a feed

Similar Threads

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