English 中文(简体)
如何制定小型方案?
原标题:How to program a small program?

I would like to program productive and keep my FileSize very small. However I would like to know a few tips how do accomplish that.

举例来说,小案卷越好:

分别:

if .... =  1  then begin
 ...
end;

if ..... = inttostr(1) then begin
...
end;

if .... = inttostr($0001) then begin
...
end;

case of intvar
  1: ...
  2: ...
end;

Then there is something that I tried and I was surprised. I made another Unit in my project that stores Strings as constants and then I use the constant vars to replace the strings in my project. For some reason this raises my FileSize although I replace double used Strings as a var now.

Also is it better to store stuff in vars than put them directly into the code?! For example:

Function1(param1, param2, param3); // this code is used about 20 times in my project

如果我:

Avar = Function1 (param1,param2,param3); // Store this once in a var and then replace it

关于:

if ... = TRUE 

if ....

如下:

if .... = FALSE

if not(...)...

为较小的档案制作节目的任何其他渠道?

提前感谢。

I use Delphi7

最佳回答

我很抱歉要bl,但你正在把车放在马上。

如果你真的想要知道如何使你无法执行,而现在又不知道你在具体事例中的法律差异将产生什么差异,那么,你就应当停止现在的到来,读/学习/实践,直到你更多地了解语言和汇编者。

然后,你理解,你的问题本身没有什么意义,正如你已经看到的所有有关意见一样。

  • the exact same source code can result in vastly different executables and different source code can result in the same executable, depending on the compiler options/optimizations
  • if your main goal is to micro-manage/control the generated exe, program directly in assembler.
  • if you want to know what is generated by the compiler, learn how to use the CPU View.
  • program for correctness first, then readability/maintainability
  • only then, if needed (implies using correct metrics/tools), you can optimize for speed, memory usage or file size (probably the least useful/needed)
问题回答

很久以前,我就试图使方案尽可能小,因为它必须安装在一盘fl盘上(一只知道一米一只din。 这个Splitter工具是在Delphi撰写的,规模约为50KB。

要想达到这一小点,就必须在没有许多Delphi的单位(特别是Forms/code>单位和所有提及该单位的单位)的情况下这样做。 唯一的办法是将Windows-API直接用于全球倡议,而且可以想到现在这样做的理由,但出于兴趣。

一旦你们使用《世界森林公约》,其面积就会大大提高,而你们的法典中的所有微量优化都会减少。





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...