Eliminating Seperate Function in While Loop

This is a discussion on Eliminating Seperate Function in While Loop within the C# Programming forums, part of the General Programming Boards category; This problem would probably have the same solution in all the "C" languages, but the code is C# so I ...

  1. #1
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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, 01: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, 07:26 PM
  4. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM

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