小编Ond*_*lka的帖子

汇编程序推送rdi,pop rdi函数调用

在C++中调用函数时,推rdi和pop rdi的目的是什么?VS2010,x64,调试,没有优化

C++

int calc()
{
    return 8 + 7;
}
Run Code Online (Sandbox Code Playgroud)

拆卸:

int calc()
{
000000013F0B1020  push        rdi  
    return 8 + 7;
000000013F0B1022  mov         eax,0Fh  
}
000000013F0B1027  pop         rdi  
000000013F0B1028  ret 
Run Code Online (Sandbox Code Playgroud)

c++ 64-bit assembly x86-64

2
推荐指数
1
解决办法
3119
查看次数

List.OfType()速度,替代数据结构

看看这段代码.

interface ILoader
{
}

interface ILoader<T>: ILoader
{
    T Load();
}

class CarLoader: ILoader<Car>
{
    ...
}

class TrainLoader: ILoader<Train>
{
    ...
}

class Container
{
     List<ILoader> loaders = new ILoader[] { new CarLoader(), new TrainLoader()};

     public T Load<T>()
     {
         // Finding right loader
         var loader = loaders.OfType<ILoader<Car>>.FirstOrDefault();
         return loader.Load();
     }
}
Run Code Online (Sandbox Code Playgroud)

我有大约100个装载机,我需要加载很多火车,汽车等.我认为装载机列表非常慢(有OfType()线性复杂性??),你建议使用什么而不是列表?Dictionary<Type,ILoader>Hashtable<Type,ILoader>HashSet<ILoader>?例如使用hashset.OfType<ILoader<Car>>(),列表或更快的速度有多快?

c# linq collections complexity-theory oftype

0
推荐指数
1
解决办法
1167
查看次数

标签 统计

64-bit ×1

assembly ×1

c# ×1

c++ ×1

collections ×1

complexity-theory ×1

linq ×1

oftype ×1

x86-64 ×1