forked from bingwong2010/RocketMQ
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from dltc/master
纯Java实现的CRC32算法, 代替原来的调用native方法的实现,可以提升每条消息计算CRC32的速度.
- Loading branch information
Showing
2 changed files
with
619 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -190,7 +191,7 @@ public static String timeMillisToHumanString2(final long t) { | |
/** | ||
* 返回日期时间格式,精度到秒<br> | ||
* 格式如下:2013122305190000 | ||
* | ||
* | ||
* @param t | ||
* @return | ||
*/ | ||
|
@@ -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); | ||
} | ||
|
Oops, something went wrong.