Skip to content

Commit

Permalink
Merge pull request #240 from dltc/master
Browse files Browse the repository at this point in the history
纯Java实现的CRC32算法, 代替原来的调用native方法的实现,可以提升每条消息计算CRC32的速度.
  • Loading branch information
vintagewang committed Apr 22, 2016
2 parents 2502246 + ede8bb8 commit 4d24a56
Show file tree
Hide file tree
Showing 2 changed files with 619 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;

import com.alibaba.rocketmq.common.utils.PureJavaCrc32;
import com.alibaba.rocketmq.remoting.common.RemotingHelper;


/**
* 各种方法大杂烩
*
*
* @author shijia.wxr<[email protected]>
*/
public class UtilAll {
Expand Down Expand Up @@ -190,7 +191,7 @@ public static String timeMillisToHumanString2(final long t) {
/**
* 返回日期时间格式,精度到秒<br>
* 格式如下:2013122305190000
*
*
* @param t
* @return
*/
Expand Down Expand Up @@ -248,7 +249,7 @@ public static final int crc32(byte[] array) {


public static final int crc32(byte[] array, int offset, int length) {
CRC32 crc32 = new CRC32();
PureJavaCrc32 crc32 = new PureJavaCrc32();
crc32.update(array, offset, length);
return (int) (crc32.getValue() & 0x7FFFFFFF);
}
Expand Down
Loading

0 comments on commit 4d24a56

Please sign in to comment.