- Notifications
You must be signed in to change notification settings - Fork 1.1k
fix negative number to uint #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@ ## master #106 +/- ## ========================================= + Coverage 62.17% 63.28% +1.1% ========================================= Files 60 60 Lines 5385 5387 +2 ========================================= + Hits 3348 3409 +61 + Misses 1812 1759 -53 + Partials 225 219 -6
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该把改动控制在 any 里就可以了。应该读一下any 的 buf 的第一个byte就可以处理。不要去改 iterator。
feature_iter_int.go Outdated
| ||
func (iter *Iterator) ReadUint() uint { | ||
if iter.buf[iter.head] == '-' && len(iter.buf) > 1 { | ||
iter.buf = iter.buf[1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样写是有问题的。buf 的当前位置不是0,是 iter.n。你得了解整个iterator维护当前进度的方式再来改这块。
feature_iter_int.go Outdated
} | ||
| ||
func (iter *Iterator) ReadUint64() uint64 { | ||
if iter.buf[iter.head] == '-' && len(iter.buf) > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么要加这样的判断?如果是负数,读取的时候应该报错啊。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
php里没有uint,不过直接把负值全扔掉也不好吧orz
不太确定,我再想想
又想了想,go自己也是不支持负值向uint转换的,还是保留原来转成0的逻辑吧orz |
feature_any_string.go Outdated
pointOccurCnt := 0 | ||
pointPos := -1 | ||
| ||
for i := startPos; i < len(any.val); i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥有这么复杂……
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
想兼容一些恶心的string,比如123.12asd这种,因为php里强转能转出一个值来orz,要是不兼容就简单了。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
简单点吧,这个太复杂了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还用标准库的ParseFloat么
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对啊。any 是 skip 出来的。你那样的数字都skip不出来。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int的先不改。。看起来还像还不算太复杂
fix negative number to uint