0%

使用命令

1
git remote set-url --add origin <仓库URI>

直接修改仓库config

编辑仓库下.git/config的配置文件,下面是一个例子:

1
2
3
4
5
[remote "origin"]
url = <仓库1-URI>
fetch = +refs/heads/*:refs/remotes/origin/*
url = <仓库2-URI>

上面两个修改的效果是一样的,使用命令实际上也是在.git/config中添加配置

推送

这是用直接用origin来推送就可以了,git会向origin中记录的两个仓库提交

1
git push origin master

likely和unlikely的用途

对于条件选择语句,gcc内建了一条指令(__builtin_expect)用于优化,在一个条件经常出现,或者该条件很少出现的时候,编译器可根据这条指令对条件分支选择进行优化

在Linux内核中把这条指令封装成了likely和unlikely宏,广泛用于条件分支选择语句上。

gcc生效条件

如果想要__builtin_expect这条指令起作用的话,最起码要O2的优化级别

1
gcc -O2 ...

使用方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 普通条件分支选择语句
if (a) {
// ...
} else {
// ...
}

// likely,判断为a在大多数情况下为真
if (likely(a)) {
// ...
} else {
// ...
}

// unlikely,判断为a在大多数情况下为假
if (unlikely(a)) {
// ...
} else {
// ...
}

实现原理

likely和unlikely在linux内核源码上其实就是宏,它们封装了__builtin_expect指令

阅读全文 »

  1. 登录
1
docker login
  1. 给Image的tag加上个人docker账户的前缀
1
docker tag lcserver phantom27/lcserver
  1. 推送
1
docker push phantom27/lcserver

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Language: Cpp
Standard: Cpp11
UseTab: Never
TabWidth: 4
IndentWidth: 4
AccessModifierOffset: -4
# AccessModifierOffset: 2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
# AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: true
# AlignConsecutiveMacros: false
AlignEscapedNewlines: Right
# AlignOperands: AlignAfterOperator
AlignTrailingComments: true
# AllowAllArgumentsOnNextLine: false
# AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
# AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
# AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
# BitFieldColonSpacing: Both
BreakBeforeBraces: Custom # Allman
BraceWrapping:
# AfterCaseLabel: true
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
# BeforeLambdaBody: false
# BeforeWhile: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: false
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerIndentWidth: 2
Cpp11BracedListStyle: true
PointerAlignment: Left
FixNamespaceComments: true
IncludeBlocks: Preserve
# IndentCaseBlocks: false
IndentCaseLabels: true
# IndentGotoLabels: false
# IndentPPDirectives: BeforeHash
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
# SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
# SpaceBeforeCpp11BracedList: false
SpaceBeforeParens: ControlStatements
# SpaceBeforeRangeBasedForLoopColon: true
# SpaceBeforeSquareBrackets: false
# SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
# SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
ContinuationIndentWidth: 4

更多风格定制可以参看:Clang-Format Style Options