NewDCollatedString is a helper routine to create a *DCollatedString. Panics if locale is invalid. Not safe for concurrent use.
( contents string, locale string, env *CollationEnvironment, )
| 1362 | // NewDCollatedString is a helper routine to create a *DCollatedString. Panics |
| 1363 | // if locale is invalid. Not safe for concurrent use. |
| 1364 | func NewDCollatedString( |
| 1365 | contents string, locale string, env *CollationEnvironment, |
| 1366 | ) (*DCollatedString, error) { |
| 1367 | entry, err := env.getCacheEntry(locale) |
| 1368 | if err != nil { |
| 1369 | return nil, err |
| 1370 | } |
| 1371 | if env.buffer == nil { |
| 1372 | env.buffer = &collate.Buffer{} |
| 1373 | } |
| 1374 | key := entry.collator.KeyFromString(env.buffer, contents) |
| 1375 | d := DCollatedString{contents, entry.locale, make([]byte, len(key))} |
| 1376 | copy(d.Key, key) |
| 1377 | env.buffer.Reset() |
| 1378 | return &d, nil |
| 1379 | } |
| 1380 | |
| 1381 | // AsDCollatedString attempts to retrieve a DString from an Expr, returning a AsDCollatedString and |
| 1382 | // a flag signifying whether the assertion was successful. The function should |
no test coverage detected
searching dependent graphs…