版本比较
P10815 【模板】快速读入 题解
正文
增加 3 行删除 3 行
62 行未改动63646566676869707116 行未改动88899091929394959617 行未改动11411511611711811912012112226 行未改动62 行未改动我们可以在 `int` 前面加个 `inline`,`inline`(内联)对于多次调用的函数有着非常明显的加速作用,而快读明显非常常用。关于 `inline` 的优缺点:优点:对于一些较小的函数,如果频繁调用,可以将其设计为内联函数,省去了执行函数地址转移等操作,占用系统资源更少,执行效率更高。缺点:如果调用内联函数的地方太多,就会造成代码膨胀,因为编译器会把每个调用内联函数的位置都拷贝一份函数实现嵌入其中,重复的嵌入。#### 对于 `x = x * 10 + (ch - '0'); `16 行未改动inline int read(){int x = 0, f = 1;char ch = getchar_unlocked();while (!isdigit(ch)){if (ch == '-')f = -1;ch = getchar_unlocked();}while (isdigit(ch)){17 行未改动inline int read(){int x = 0, f = 1;char ch = getchar_unlocked();while (!isdigit(ch)){if (ch == '-')f = -1;ch = getchar_unlocked();}while (isdigit(ch)){26 行未改动62 行未改动63646566676869707116 行未改动88899091929394959617 行未改动11411511611711811912012112226 行未改动62 行未改动我们可以在 `int` 前面加个 `inline`,`inline`(内联)对于多次调用的函数有着非常明显的加速作用,而快读明显非常常用。关于 `inline` 的优缺点:优点:对于一些较小的函数,如果频繁调用,可以将其设计为内联函数,省去了执行函数地址转移等操作,占用系统资源更少,执行效率更高。缺点:如果调用内联函数的地方太多,就会造成代码膨胀,因为编译器会把每个调用内联函数的位置都拷贝一份函数实现嵌入其中,重复的嵌入。#### 对于 `x = x * 10 + (ch - '0'); `16 行未改动inline int read(){int x = 0, f = 1;char ch = getchar_unlocked();while (!isdigit(ch)){if (ch == '-')f = -1;ch = getchar_unlocked();}while (isdigit(ch)){17 行未改动inline int read(){int x = 0, f = 1;char ch = getchar_unlocked();while (!isdigit(ch)){if (ch == '-')f = -1;ch = getchar_unlocked();}while (isdigit(ch)){26 行未改动