我正在对我的网站进行最后的修改,并且正在努力使页面的负载看起来不那么紧张.最好的方式向您展示我的意思是显示该网站:http: //marckremers.com/2011(仍未完成,处于alpha阶段)
正如您所看到的,内容粘在左侧,将大量的jquery和图像加载到页面中,然后单击到位(中心).
我想知道是否有一种方法可以让它先点击到位然后加载元素?
我尝试将重新定位脚本放在后面,甚至没有用.
有任何想法吗?谢谢
这就是我一直在使用的:
for i in iter(SHAPES):
SHAPES[i].drawOrder(97)
SHAPES[i].alpha(CFG["SHP_alpha"])
.
.
Run Code Online (Sandbox Code Playgroud)
这就是我的想法:
for i, v in app.SHAPES.items():
v.drawOrder(97)
v.alpha(CFG["SHP_alpha"])
.
.
Run Code Online (Sandbox Code Playgroud)
我应该使用哪两个?有没有其他方法可以做到这一点?
什么是更好的编码实践,为什么?
string str1 = textBox1.Text;
string str2 = textBox2.Text;
void FunctionName (str1, str2);
Run Code Online (Sandbox Code Playgroud)
要么
void FunctionName(textBox1.Text, textBox2.Text);
Run Code Online (Sandbox Code Playgroud) 我现在正在编写用于图像处理的小应用程序.但是我的程序内存使用存在很大问题.我是c ++的新手,以前我主要用c#编程.
几乎所有工作的功能都是这样的
while(!prototypeVector[i]->GetIsConvergaed())
{
if(previousPrototype!=NULL) delete previousPrototype;
previousPrototype = prototypeVector[i]->CopyPrototype();
if(&matchingPointVector!=NULL) matchingPointVector.clear();
matchingPointVector = prototypeVector[i]->CalculateMatchingPointsAll(imageDataVector);
distanseMatrix = CalculateDistanceAll(i);
membershipMatrix = UpdateMembershipAll(i);
if(translation)
{
tmatrix = UpdateTranslationMatrix(i);
if(directUpdate) prototypeVector[i]->SetTranslationMatrix( tmatrix);
//prototypeVector[i]->GetTranslationMatrix().DisplayMatrix();
tmatrix.DisplayMatrix();
}
if(scaling)
{
smatrix = UpdateScalingMatrix(i);
if(directUpdate) prototypeVector[i]->SetScalingMatrix(smatrix);
smatrix.DisplayMatrix();
}
if(rotation)
{
angle = UpdateAngleCoefficient(i);
cout<<endl;
Convert::RadiansToDegrees(angle)<<endl;
if(directUpdate)prototypeVector[i]->UpdateRotationMatrix(angle);
}
prototypeVector[i]->TransformTemplateOne(prototypeVector[i]->GetRotationMatrix(), prototypeVector[i]->GetScalingMatrix() , prototypeVector[i]->GetTranslationMatrix());
}
Run Code Online (Sandbox Code Playgroud)
我注意到如果在上面写的函数被称为另一个函数
CalculateMatchingPointsAll或CalculateDistanceAll或UpdateScalingMatrix内存使用率大幅上升(执行上述每个函数后300kB).所以我认为问题出在这些功能上.他们看起来像那样
vector<Point*> TemplateClusterPoint::CalculateMatchingPointsAll( vector<Point*> imageDataVector)
{
vector<Point*> matchinPointVector = vector<Point*>(imageDataVector.size(),new Point(0,0));
double minValue = DOUBLE_MAX_VALUE;
double currentDistance = 0;
for (int i=0;i<imageDataVector.size();i++ ) …Run Code Online (Sandbox Code Playgroud) 因此,您可以选择构建数组,因为您知道在代码中需要检查数组中是否存在值.我看到它的方式至少有两个选择:
$values_array = array(
'my_val',
'my_val2',
'and_so_on',
);
if(in_array('my_val', $values_array)) {
var_dump('Its there!');
}
Run Code Online (Sandbox Code Playgroud)
或者您可以使用关联数组并使用键来包含您的值:
$values_array = array(
'my_val' => '',
'my_val2' => '',
'and_so_on' => '',
);
if(isset($values_array['my_val'])) {
var_dump('Its there!');
}
Run Code Online (Sandbox Code Playgroud)
你会选择哪种方法?为什么?您是否只是为了减少处理时间或减少使用的内存量?
也许你不会使用我的两个微不足道的方法,并有另一种很棒的方法来解决这个简单的问题.
这是一个没有考虑真实世界应用的理论问题,但阵列中可能有数千个选项.这是一个推测性的问题,真正看到每个人都认为哪种方法更好.是否因为可读性,速度或内存使用原因而被认为是这样.
假设你想制作一个会反复打印数字1-9的程序
123456789123456789123456789
我想最明显的方法是使用循环
int number = 1;
while(true)
{
print(number);
number = number + 1;
if(number > 9)
number = 1;
}
Run Code Online (Sandbox Code Playgroud)
在我继续前进之前,这是最好的方法吗?或者有更常见的方法吗?
我想在下面的代码值类型中找出更有效(如果是甚至)的内容
ForEach(string s in strings)
{
string t = s;
}
// or
string t;
ForEach(string s in strings)
{
t = s;
}
Run Code Online (Sandbox Code Playgroud)
和引用类型有什么不同.
是否有可能使这个脚本更快?
#!/usr/bin/perl -w
use strict;
use CGI;
package SwitchGUI;
sub new {
my ($classe, $nom, $nbports, $gio) = @_;
my $this = {
"nom" => $nom,
"nbports" => $nbports,
"gio" => $gio
};
bless($this, $classe);
$this->afficher();
return $this;
}
sub afficher {
my ($this) = @_;
my @tab = ( 1 .. $this->{nbports} );
my @odd = grep { $_ % 2 } @tab;
my @even = grep { not $_ % 2 } @tab;
my $cgi = new CGI; …Run Code Online (Sandbox Code Playgroud) 有没有更好的办法?请注意,我没有使用,fixed因为我需要扫描缓冲区数据.
GCHandle pinned1 = GCHandle.Alloc(Pic1, GCHandleType.Pinned);
IntPtr ptr1 = pinned1.AddrOfPinnedObject();
byte* p1 = (byte*)ptr1.ToPointer();
//...
//...
//...
byte a=*p1;
p1++;
//...
//...
pinned1.Free();
Run Code Online (Sandbox Code Playgroud) 在gcc中启用1级优化后,我遇到了一个奇怪的问题.我所做的是稍后将标签和jmp从其他功能保存回来.
void
UMS__suspend_procr( VirtProcr *animatingPr )
{
animatingPr->nextInstrPt = &&ResumePt;
[Some Code and inline volatile asm]
ResumePt:
return;
Run Code Online (Sandbox Code Playgroud)
}
我做了一些跳跃,他们都工作正常.问题是,当我打开O1时,它不会保存正确的标签地址.相反,它这样做:
804b14e: 8b 45 08 mov 0x8(%ebp),%eax
804b151: c7 40 14 4e b1 04 08 movl $0x804b14e,0x14(%eax)
804b158: 8b 55 08 mov 0x8(%ebp),%edx
Run Code Online (Sandbox Code Playgroud)
所以程序甚至在分配之前就会跳回来.