mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:33:04 +08:00
Merge pull request #206 from songleo/master
review chapter 18 , and append my info to readme
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
- [@leisore](https://github.com/leisore)
|
- [@leisore](https://github.com/leisore)
|
||||||
- [@dake](https://github.com/dake)
|
- [@dake](https://github.com/dake)
|
||||||
- [@glight2000](https://github.com/glight2000)
|
- [@glight2000](https://github.com/glight2000)
|
||||||
|
- [@songleo](https://github.com/songleo)
|
||||||
|
|
||||||
## 授权许可
|
## 授权许可
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
- [@leisore](https://github.com/leisore)
|
- [@leisore](https://github.com/leisore)
|
||||||
- [@dake](https://github.com/dake)
|
- [@dake](https://github.com/dake)
|
||||||
- [@glight2000](https://github.com/glight2000)
|
- [@glight2000](https://github.com/glight2000)
|
||||||
|
- [@songleo](https://github.com/songleo)
|
||||||
|
|
||||||
## 适用人群
|
## 适用人群
|
||||||
|
|
||||||
|
@@ -34,6 +34,8 @@ for ix, ch := range str {
|
|||||||
|
|
||||||
最快速:`utf8.RuneCountInString(str)`
|
最快速:`utf8.RuneCountInString(str)`
|
||||||
|
|
||||||
|
`len([]int(str))`
|
||||||
|
|
||||||
(5)如何连接字符串:
|
(5)如何连接字符串:
|
||||||
|
|
||||||
最快速:
|
最快速:
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
(4)尽可能的使用数组和切片代替映射(详见参考文献15);
|
(4)尽可能的使用数组和切片代替映射(详见参考文献15);
|
||||||
|
|
||||||
(5)如果只想获取切片中某项值,不需要值的索引,尽可能的使用`for range`去遍历切片,这比必须去查询切片中的每个元素要快一些;
|
(5)如果只想获取切片中某项值,不需要值的索引,尽可能的使用`for range`去遍历切片,这比必须查询切片中的每个元素要快一些;
|
||||||
|
|
||||||
(6)当数组元素是稀疏的(例如有很多`0`值或者空值`nil`),使用映射会降低内存消耗;
|
(6)当数组元素是稀疏的(例如有很多`0`值或者空值`nil`),使用映射会降低内存消耗;
|
||||||
|
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
出于性能考虑的建议:
|
出于性能考虑的建议:
|
||||||
|
|
||||||
实践经验表明,如果你使用并行计算获得高于串行运算的效率:在协程内部已经完成的大部分工作,其开销比创建协程和协程间通信还高。
|
实践经验表明,如果你使用并行运算获得高于串行运算的效率:在协程内部已经完成的大部分工作,其开销比创建协程和协程间通信还高。
|
||||||
|
|
||||||
1 出于性能考虑建议使用带缓存的通道:
|
1 出于性能考虑建议使用带缓存的通道:
|
||||||
|
|
||||||
使用带缓存的通道可以很轻易成倍提高它的吞吐量,某些场景其性能可以提高至10倍甚至更多。通过调整通道的容量,你可以尝试着更进一步的优化其性能。
|
使用带缓存的通道可以很轻易成倍提高它的吞吐量,某些场景其性能可以提高至10倍甚至更多。通过调整通道的容量,甚至可以尝试着更进一步的优化其性能。
|
||||||
|
|
||||||
2 限制一个通道的数据数量并将它们封装成一个数组:
|
2 限制一个通道的数据数量并将它们封装成一个数组:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user