Skip to content

Comments

split#2

Open
ChenChen1113 wants to merge 2 commits intobaishancloud:masterfrom
ChenChen1113:master
Open

split#2
ChenChen1113 wants to merge 2 commits intobaishancloud:masterfrom
ChenChen1113:master

Conversation

@ChenChen1113
Copy link
Contributor

split lch_new.

consistenthash.c Outdated

static int
node_cmp( const hashnode_t *a, const hashnode_t *b )
node_cmp( const hashnode_t *a, const hashnode_t *b ) /*for qsort below, sort from small to large*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释一般都单起1行.不要放在代码中间.

consistenthash.c Outdated


while ( s + 1 < e ) {
while ( s + 1 < e ) { /*binary search*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你的vim里有NERD-Comment这个插件. ctrl-f切换注释.

consistenthash.c Outdated


p = get_continuum( L, 1 );
p = get_continuum( L, 1 ); /*get the storage address for userdata*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是很关键的注释自己看就好了..不用提交上来.

consistenthash.c Outdated
if ( lua_isnumber( L, 3 ) ) {
n_replica = lua_tointeger( L, 3 );
if ( n_replica > MAX_REPLICA ) {
if ( n_replica > MAX_REPLICA ) { /*the number of replica nodes is limited to MAX_REPLICA*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类似这种注释没啥用处..

consistenthash.c Outdated
#include <lua.h>
#include <lauxlib.h>

#include"md5.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注意空格

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

装个astyle, 专门用来格式化c代码的.

这里是配置文件, 放到 ~/.astylerc

#Bracket style
style=google

#Tab
#使用2个空格作为一个缩进单位
indent=spaces=4

#Indentation
#缩进case本身
indent-switches
#缩进case内容
indent-cases
#缩进宏定义内容
# indent-preproc-block
# indent-preproc-cond
# indent-preproc-define
#缩进注释
indent-col1-comments

#Padding
#操作符两端补空格
pad-oper
#if/for/while后面与小括号之间补空格
pad-header
#除上述两点外,都不补空格
unpad-paren
#声明指针时,*贴紧变量名
align-pointer=name

#Formatting
#单行的分支循环块补充花括号
add-brackets
#凡是tab都替换成两个空格
convert-tabs
#单行最长100个字节
max-code-length=100
#单行长度超过100字节时根据条件逻辑进行切分换行
break-after-logical
#c/c++风格
mode=c
#保持一行代码的写法
keep-one-line-blocks

#Other
#转化后的文件修改时间不变
preserve-date
#linux风格的换行符
lineend=linux
#show detail
verbose

# do not create backup
suffix=none

@@ -0,0 +1,15 @@
typedef struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.h头文件要加重复include的判断.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯嗯

consistenthash.c Outdated

while ( s + 1 < e ) {
mid = ( s+e ) / 2;
mid = ( s+e ) ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what??

consistenthash.c Outdated
if ( lua_isnumber( L, 3 ) ) {
n_replica = lua_tointeger( L, 3 );
if ( n_replica > MAX_REPLICA ) {
if ( n_replica > MAX_REPLICA ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注意tab和space.都用space

consistenthash.c Outdated

while ( n_names < n_replica ) {

/* assignment */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个注释有啥用啊..

consistenthash.c Outdated

if ( 0 == n ) {
luaL_argerror( L, 2, "Empty table" );
luaL_argerror( L, 2, "Empty table" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tab...

consistenthash.c Outdated
for ( i = 0; i < conti->n_buckets; i++ ) {
i_nodes = point_search( conti, step * i );
conti->buckets[ i ] = i_nodes;
conti->buckets[ i ] = i_nodes; /*map the node to a bucket*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

尽量不用尾注释

@drmingdrmer
Copy link
Contributor

测试跑过了没~

md5.h Outdated
@@ -0,0 +1,19 @@
#ifndef MD5_H
#define MD5_H
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看看c preprocessor的例子和教程.这个endif加的不对

Makefile Outdated

LUAPKG = lua5.2
CFLAGS = `pkg-config $(LUAPKG) --cflags` -fPIC -O3 -Wall $(OMIT_FRAME_PTR)
CFLAGS = `pkg-config $(LUAPKG) --cflags` -fPIC -O3 -Wall $(OMIT_FRAME_PTR) -I/usr/local/include/luajit-2.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方不能直接用带版本的绝对路径..不是所有的机器上都装的2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants