[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [goptlib/master] Use switch for keywordIsSafe.
commit 24207cb5ab5c782d70e29a837c8aeef8e01d61f5
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Mon Jun 26 16:48:59 2017 -0700
Use switch for keywordIsSafe.
---
pt.go | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/pt.go b/pt.go
index 6b0dd09..39e6aca 100644
--- a/pt.go
+++ b/pt.go
@@ -217,19 +217,18 @@ func getenvRequired(key string) (string, error) {
// <KeywordChar> ::= <any US-ASCII alphanumeric, dash, and underscore>
func keywordIsSafe(keyword string) bool {
for _, b := range []byte(keyword) {
- if b >= '0' && b <= '9' {
+ switch {
+ case b >= '0' && b <= '9':
continue
- }
- if b >= 'A' && b <= 'Z' {
+ case b >= 'A' && b <= 'Z':
continue
- }
- if b >= 'a' && b <= 'z' {
+ case b >= 'a' && b <= 'z':
continue
- }
- if b == '-' || b == '_' {
+ case b == '-' || b == '_':
continue
+ default:
+ return false
}
- return false
}
return true
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits