`
mryufeng
  • 浏览: 968856 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

R14A实现了EEP31,添加了binary模块

阅读更多
Erlang的binary数据结构非常强大,而且偏向底层,在作网络程序的时候,很方便的能够和二进制协议对应起来。但是由于这个数据结构加入erlang语言的时间不是很长,相关的配套模块不是很多。 在binary的匹配,替换,修改就显的非常麻烦。 于是有了EEP31 。 R14A昨天已经实现了这个功能, 在stdlib下添加了个binary模块。 这个模块大部分功能是由BIF实现的,同时充分考虑了CPU使用的公平性,源码大部分在erl_bif_binary.c下。 还添加了个gurad函数: binary_part进一步方便我们写匹配条件。

我们在源码里面发现了以下注释:
/*
* The native implementation functions for the module binary.
* Searching is implemented using aither Boyer-More or Aho-Corasick
* depending on number of searchstrings (BM if one, AC if more than one).
* Native implementation is mostly for efficiency, nothing
* (except binary:referenced_byte_size) really *needs* to be implemented
* in native code.
*/

这个模块兼顾了效率和方便性,使用起来就大大简化了代码的复杂度,有福气了。
分享到:
评论
2 楼 mryufeng 2010-05-27  
Erlang的IO没用错的话大概有顶级程序员写的80%!
1 楼 121598351 2010-05-27  
你好~mryufeng!我在网上查到有人评价erlang的I/O性能不好,但是我在你的BLOG中看到你说erlang的I/O很高效的
请问你说的意思是不是和c/c++的差距比较小?谢谢!

相关推荐

Global site tag (gtag.js) - Google Analytics