Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vereign Client Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
Vereign Client Library
Commits
eb87cfa1
Commit
eb87cfa1
authored
6 years ago
by
Alexander Holodov
Browse files
Options
Downloads
Patches
Plain Diff
18 remove unused code
parent
2b9b13a2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.go
+1
-123
1 addition, 123 deletions
main.go
with
1 addition
and
123 deletions
main.go
+
1
−
123
View file @
eb87cfa1
package
main
package
main
import
(
import
(
"
bytes
"
"
code.vereign.com/code/restful-api/server
"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"os"
...
@@ -10,9 +10,6 @@ import (
...
@@ -10,9 +10,6 @@ import (
"sort"
"sort"
"strings"
"strings"
"unicode"
"unicode"
"unicode/utf8"
"code.vereign.com/code/restful-api/server"
)
)
func
main
()
{
func
main
()
{
...
@@ -164,129 +161,11 @@ func buildViamAPI() string {
...
@@ -164,129 +161,11 @@ func buildViamAPI() string {
return
result
return
result
}
}
const
(
caseMask
=
^
byte
(
0x20
)
// Mask to ignore case in ASCII.
kelvin
=
'\u212a'
smallLongEss
=
'\u017f'
)
// equalFoldRight is a specialization of bytes.EqualFold when s is
// known to be all ASCII (including punctuation), but contains an 's',
// 'S', 'k', or 'K', requiring a Unicode fold on the bytes in t.
// See comments on foldFunc.
func
equalFoldRight
(
s
,
t
[]
byte
)
bool
{
for
_
,
sb
:=
range
s
{
if
len
(
t
)
==
0
{
return
false
}
tb
:=
t
[
0
]
if
tb
<
utf8
.
RuneSelf
{
if
sb
!=
tb
{
sbUpper
:=
sb
&
caseMask
if
'A'
<=
sbUpper
&&
sbUpper
<=
'Z'
{
if
sbUpper
!=
tb
&
caseMask
{
return
false
}
}
else
{
return
false
}
}
t
=
t
[
1
:
]
continue
}
// sb is ASCII and t is not. t must be either kelvin
// sign or long s; sb must be s, S, k, or K.
tr
,
size
:=
utf8
.
DecodeRune
(
t
)
switch
sb
{
case
's'
,
'S'
:
if
tr
!=
smallLongEss
{
return
false
}
case
'k'
,
'K'
:
if
tr
!=
kelvin
{
return
false
}
default
:
return
false
}
t
=
t
[
size
:
]
}
if
len
(
t
)
>
0
{
return
false
}
return
true
}
// asciiEqualFold is a specialization of bytes.EqualFold for use when
// s is all ASCII (but may contain non-letters) and contains no
// special-folding letters.
// See comments on foldFunc.
func
asciiEqualFold
(
s
,
t
[]
byte
)
bool
{
if
len
(
s
)
!=
len
(
t
)
{
return
false
}
for
i
,
sb
:=
range
s
{
tb
:=
t
[
i
]
if
sb
==
tb
{
continue
}
if
(
'a'
<=
sb
&&
sb
<=
'z'
)
||
(
'A'
<=
sb
&&
sb
<=
'Z'
)
{
if
sb
&
caseMask
!=
tb
&
caseMask
{
return
false
}
}
else
{
return
false
}
}
return
true
}
// simpleLetterEqualFold is a specialization of bytes.EqualFold for
// use when s is all ASCII letters (no underscores, etc) and also
// doesn't contain 'k', 'K', 's', or 'S'.
// See comments on foldFunc.
func
simpleLetterEqualFold
(
s
,
t
[]
byte
)
bool
{
if
len
(
s
)
!=
len
(
t
)
{
return
false
}
for
i
,
b
:=
range
s
{
if
b
&
caseMask
!=
t
[
i
]
&
caseMask
{
return
false
}
}
return
true
}
func
foldFunc
(
s
[]
byte
)
func
(
s
,
t
[]
byte
)
bool
{
nonLetter
:=
false
special
:=
false
// special letter
for
_
,
b
:=
range
s
{
if
b
>=
utf8
.
RuneSelf
{
return
bytes
.
EqualFold
}
upper
:=
b
&
caseMask
if
upper
<
'A'
||
upper
>
'Z'
{
nonLetter
=
true
}
else
if
upper
==
'K'
||
upper
==
'S'
{
// See above for why these letters are special.
special
=
true
}
}
if
special
{
return
equalFoldRight
}
if
nonLetter
{
return
asciiEqualFold
}
return
simpleLetterEqualFold
}
// A field represents a single field found in a struct.
// A field represents a single field found in a struct.
type
field
struct
{
type
field
struct
{
name
string
name
string
nameBytes
[]
byte
// []byte(name)
nameBytes
[]
byte
// []byte(name)
equalFold
func
(
s
,
t
[]
byte
)
bool
// bytes.EqualFold or equivalent
tag
bool
tag
bool
index
[]
int
index
[]
int
...
@@ -297,7 +176,6 @@ type field struct {
...
@@ -297,7 +176,6 @@ type field struct {
func
fillField
(
f
field
)
field
{
func
fillField
(
f
field
)
field
{
f
.
nameBytes
=
[]
byte
(
f
.
name
)
f
.
nameBytes
=
[]
byte
(
f
.
name
)
f
.
equalFold
=
foldFunc
(
f
.
nameBytes
)
return
f
return
f
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment