Thread: GCD as fast as possible!

  1. #16
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    You do realize that most IDE's can be setup to automatically replace tabs with spaces. So its always the same indentation. Also with any half arsed IDE it'll automatically format it for ya.

  2. #17
    Registered User fischerandom's Avatar
    Join Date
    Aug 2005
    Location
    Stockholm
    Posts
    71
    Quote Originally Posted by Thantos
    You do realize that most IDE's can be setup to automatically replace tabs with spaces. So its always the same indentation. Also with any half arsed IDE it'll automatically format it for ya.
    Thank you for the tip! Yes I know this, and I love the way CodeWarrior's IDE formats code! But as I said earlier, I don't like to replace my tabs with spaces before I post code here. And I really hate to deal with code that were not originally indented using tabs, but rather an arbitary amount of spaces, altering between 3 and 4 spaces, etc. And spaces after a line is virtually ended is very annoying. What are people thinking?

    Unfortunalely you guys seem more interested in this tab debate than the GCD algorithm. I just asked one simple question in the first post and now all this! I know that there is no way to make a tab appear as the length of 4 spaces on this forum and yet stay a tab. That's all I wanted to know and there is nothing more to talk about this issue.

    If you have something intelligent to say about the GCD algorithm, such as an improvement over the one I originally posted, please do.

  3. #18
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Your reluctance to replace tabs with spaces is puzzling. Your argument that some lines are indented with 3 spaces instead of 4 is completely irrelevant. If that's the case then they're going to look screwed up in your IDE anyway and replacing each tab with the same number of spaces isn't going to make it look any more screwed up. But it will make it look better when it's posted to the forum.

    And your "Using the IDE's Find and Replace does exactly the same job that itsme86 tried to acheive with his program, but is obviously much more efficient to use." just shows that you're either a whole lot greener than you lead on or you're just arguing to argue. Which do you think is more efficient? Writing a very simple command-line loop you can run this on every source file you've got very quickly. I guess opening each program individually into an IDE and doing a find and replace is your idea of "much more efficient." I know this may come as a surprise to a Mac user, but GUI interfaces aren't always the cat's meow when it comes to efficiency. They're great for some things, but this isn't one of those things. And I didn't "try" to achieve anything with the program. It does exactly what I advertised it does. Don't "try" to make it sound like it doesn't work.
    That was before I knew about the program Indent, but I think its only for Windows and I am a Mac user.
    Hardly. The program comes standard on any respectable Linux distribution. Having programmed for so many years I'm sure you've heard of GNU: ftp://ftp.gnu.org/pub/gnu/indent/

    Maybe somebody ported Indent to Windows, but there's no way that it's only for Windows and definitely didn't originate in that OS. With all of your "programming experience" it would be trivial to get the code to compile on a Mac if there isn't already a binary available.
    Last edited by itsme86; 11-22-2005 at 08:07 AM.
    If you understand what you're doing, you're not learning anything.

  4. #19
    Registered User fischerandom's Avatar
    Join Date
    Aug 2005
    Location
    Stockholm
    Posts
    71
    Yes of course it will look better on the forum, did I say anything else?

    Which do You think is more efficient? Using the program you posted to use on a command-line and run it on every source file in a project (in which case it will take anybody at least several minutes to input over 100 file names manually, and thats for medium sized projects) or do a single button click in an IDE such as Metrowerks CodeWarrior (that is relevant to the case here as I am using it) by using Find and Replace in Files. BOOM! Its done! So in this case, CodeWarriors GUI is superior to your program. I repeat, it is superior! But I never said or implied that a GUI is always better than using a command-line. This is not the case.

    I did not say or think that your program doesn't work (well you have to fix some minor things for it to run, but it is irrelevant) but I would never use it since there is a Find and Replace in Files function in the IDE I use.

    I have found no Indent application for the Mac, but of course if I need one I would probably use the Indent sources and make one. But it never had a high priority for me. I very seldomly find any good use for other peoples home-made code anyway.

  5. #20
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    You obviously have problems reading.
    Which do You think is more efficient? Using the program you posted to use on a command-line and run it on every source file in a project (in which case it will take anybody at least several minutes to input over 100 file names manually, and thats for medium sized projects) or do a single button click in an IDE such as Metrowerks CodeWarrior (that is relevant to the case here as I am using it) by using Find and Replace in Files.
    Now here's what I wrote again. This time try reading it:
    Writing a very simple command-line loop you can run this on every source file you've got very quickly.
    Since you find this so incredibly difficult to comprehend, I'll write one for you in my favorite shell, bash.
    Code:
    $ for i in *.c; do ./tabstospaces < $i > $i.modified; done
    I have 207 .c files in my C directory:
    Code:
    itsme@itsme:~/C$ ls *.c | wc -l
    207
    Now let's see just how long this really takes to fix 207 .c files!
    Code:
    itsme@itsme:~/C$ time for i in *.c; do ./tabstospaces < $i > $i.modified; done
    
    real    0m0.152s
    user    0m0.035s
    sys     0m0.104s
    itsme@itsme:~/C$
    WOW! About a tenth of a second! Can you open 207 files in your IDE and do a find and replace on each one in a tenth of a second? I didn't think so. Let's generously say it only takes you an hour to do it. That would make my method about 36,000 times faster than yours! Tell me again which is more efficient. Like I said, command-line definitely has its place. Just because you don't know how to use one advantageously doesn't mean that no one does and it certainly doesn't mean your statement is correct.
    Last edited by itsme86; 11-22-2005 at 10:18 AM.
    If you understand what you're doing, you're not learning anything.

  6. #21
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If this thread is just going to turn into an IDE / tabbing flame, then it will be closed.
    If anyone has anything else to say which is actually on topic, then say it.

  7. #22
    Registered User fischerandom's Avatar
    Join Date
    Aug 2005
    Location
    Stockholm
    Posts
    71
    Quote Originally Posted by itsme86
    Can you open 207 files in your IDE and do a find and replace on each one in a tenth of a second? I didn't think so. Let's generously say it only takes you an hour to do it. That would make my method about 36,000 times faster than yours! Tell me again which is more efficient. Like I said, command-line definitely has its place. Just because you don't know how to use one advantageously doesn't mean that no one does and it certainly doesn't mean your statement is correct.
    Obviously I can! In one tenth of a second? Yes, that is roughly the time we are speaking of, a fraction of a second. The CodeWarrior's IDE can open all files in a project and Find and Replace text in them, with a single button click - and that is a very nice and efficient way to do it. And besides there is several other ways you can do it, like in folders, in projects, in symbolics and in files, etc. This I think is superior to having to type-in a command line, its faster for to click with the mouse. BOOM! Done! OK, so you were plain wrong again as it doesn't take CodeWarrior any longer time to do it than the methode you used.

    I confess that I made a huge mistake asking one simple question in my first post which was about the possibility to set the tab length in spaces. Please forget all about that now, and let this thread continue about the Greatest Common Divisor algorithm, though it takes some brain to discuss that. I am sure there will be very little said about it, though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Gcd on three numbers
    By Ideswa in forum C Programming
    Replies: 7
    Last Post: 03-19-2009, 01:57 PM
  2. Saving a part of screen into a file fast!
    By Zap in forum C++ Programming
    Replies: 4
    Last Post: 06-28-2003, 10:56 AM
  3. Super fast bilinear interpolation
    By VirtualAce in forum Game Programming
    Replies: 2
    Last Post: 06-18-2002, 09:35 PM
  4. moving a bitmap, fast and smooth
    By werdy666 in forum Game Programming
    Replies: 1
    Last Post: 05-31-2002, 06:49 PM
  5. GCD For all of You!
    By Argentina in forum C Programming
    Replies: 0
    Last Post: 02-14-2002, 04:38 PM