zoukankan      html  css  js  c++  java
  • 读书笔记之:Efficient C++ 提高C++性能的编程技术(2003)[++]

    第1章 跟踪范例

    第2章 构造函数和析构函数

    第3章 虚函数

    1. 虚函数造成的性能损失

    第4章 返回值优化

    任何时候只要跳过了对象的创建和清除,就将会获得性能上的收益。返回值优化RVO(Return Value Optimization)是由编译器实现的优化,它用于加速源代码,是通过对源代码进行转化并消除对象的创建来实现的。

    1. 按值返回的构造

    下面是Complex类:

    class Complex{
        friend Complex operator+(const Complex &,const Complex&);
        public:
        Complex(double r=0.0,double i=0.0):real(r),imag(i){}
        Complex(const Complex& c):real(c.real),imag(c.imag){}
        Complex& operator=(const Complex& c){
            if(this!=&c){
                real=c.real;
                imag=c.imag;
            }
            return *this;
        }
        ~Complex(){}
        private:
        double real;
        double imag;
    };
    Complex operator+(const Complex&a,const Complex& b){
        Complex ret;
        ret.real=a.real+b.real;
        ret.imag=a.imag+b.imag;
        return ret;
    }                                                         

    2. 返回值优化

    3. 计算性构造函数

    第5章 临时对象

    1. 对象的定义

    2. 类型不同时的类型转换

    3. 按值传递

    第6章 单线程内存池

    第8章 内联基础

    1. 方法调用的代价

    引用计数

  • 相关阅读:
    【数据库摘要】6_Sql_Inner_Join
    C# 实体类序列化与反序列化一 (XmlSerializer)
    MBProgressHUD 显示方向异常
    回溯算法
    Linux下Tomcat VM參数改动
    053第85题
    让你提前认识软件开发(26):数据库脚本的凝视
    可穿戴设备,或许无屏交互才是终极需求!
    Tomcat载入两次问题
    python字典构造函数dict(mapping)解析
  • 原文地址:https://www.cnblogs.com/xkfz007/p/2646795.html
Copyright © 2011-2022 走看看