Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Lines of Code...

#2
As compact as possible, with verbosity coming from basic comments explaining functionality so I don't need to look too hard to find what something does.

That being said, I do mostly write native/compiled stuff, so performance benefits are usually pretty negligible. gcc and g++ automatically compile typically slow operations to faster ones, like this:
Code:
int i = 17;
int j = i / 2;
//j compiles to i >> 1, or bitshift right by one

int j = i % 2;
//compiles to i & 1 (bitwise AND with 0x1 to isolate the last bit)

The fastest or most compact even/odd calculator I've seen in C looked something like this:
Code:
#include <stdio.h>
int main(int argc, char* argv[]){
    !(argc & 1) ? return 1 : 1;
    const char* a = "odd\0even\0";
    int(argv[1]) & 1 ? printf(a) : printf(*a + 4);
    return 0;
}

Ternary operators, bitwise and pointer arithmetic. Very minified, and although I'm not actually compiling this to test it, you get the idea. The bloat comes from taking in arguments from the commandline.

I don't write huge projects or anything, so everything gets to be around a couple hundred lines, making it pretty easy to manage and generally fast to compile.
The largest code segments I've written were exploits or malware PoC's, and that's because you'd need to write shellcode as well, then compile it, rip out the .text segment from the binary, then make a byte array out of it to use with WriteProcessMemory or whatever from WinAPI/MemoryAPI.
Reply


Messages In This Thread
Lines of Code... - by Darth-Apple - March 1st, 2020 at 9:38 PM
RE: Lines of Code... - by Lain - March 1st, 2020 at 10:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What code editors do you use? Darth-Apple 6 3,031 January 19th, 2023 at 6:04 AM
Last Post: tc4me
  Object Oriented Code Darth-Apple 1 6,313 October 13th, 2014 at 3:14 PM
Last Post: Electric2Shock



Users browsing this thread: 1 Guest(s)

Dark/Light Theme Selector

Contact Us | Makestation | Return to Top | Lite (Archive) Mode | RSS Syndication 
Proudly powered by MyBB 1.8, © 2002-2024
Forum design by Makestation Team © 2013-2024