// patchTail fixes a case where a rune may be incorrectly normalized
// if it is followed by illegal continuation bytes. It returns the
// patched buffer and whether the decomposition is still in progress.
167233
func patchTail(rb *reorderBuffer) bool {
	info, p := lastRuneStart(&rb.f, rb.out)
	if p == -1 || info.size == 0 {
		return true
	}
	end := p + int(info.size)
	extra := len(rb.out) - end
	if extra > 0 {
		// Potentially allocating memory. However, this only
		// happens with ill-formed UTF-8.
		x := make([]byte, 0)
		x = append(x, rb.out[len(rb.out)-extra:]...)
		rb.out = rb.out[:end]
		decomposeToLastBoundary(rb)
		rb.doFlush()
		rb.out = append(rb.out, x...)
		return false
	}
	buf := rb.out[p:]
	rb.out = rb.out[:p]
	decomposeToLastBoundary(rb)
	if s := rb.ss.next(info); s == ssStarter {
		rb.doFlush()
		rb.ss.first(info)
	} else if s == ssOverflow {
		rb.doFlush()
		rb.insertCGJ()
		rb.ss = 0
	}
	rb.insertUnsafe(inputBytes(buf), 0, info)
	return true
}
1130383
func PatchURL(originalURL string, params ...interface{}) (patchedURL string, err error) {
	url, err := url.Parse(originalURL)
	if err != nil {
		return
	}

	query := url.Query()
	for i := 0; i < len(params)/2; i++ {
		// Check if params is key&value pair
		key := fmt.Sprintf("%v", params[i*2])
		value := fmt.Sprintf("%v", params[i*2+1])

		if value == "" {
			query.Del(key)
		} else {
			query.Set(key, value)
		}
	}

	url.RawQuery = query.Encode()
	patchedURL = url.String()
	return
}
838528
func Tail(c rune) rune {
	if TAIL_G <= c && c <= TAIL_H {
		return c
	}
	if t, ok := toTail[c]; ok {
		return t
	}

	return 0
}
739178
func (r *Router) Patch(path string, fn interface{}) *Router {
	return r.addRoute(httpMethodPatch, path, fn)
}
944100
func (r *Route) Patch(fn http.HandlerFunc) *Route {
	return r.Method(http.MethodPatch, fn)
}
1367518
func (obj *GenericDimension) ApplyPatchesRaw(ctx context.Context, patches interface{})error {
	err := obj.rpc(ctx, "ApplyPatches", nil, ensureEncodable(patches))
	return err 
}
75456
func (repo *Repository) SavePatch(index int64, patch []byte) error {
	patchPath, err := repo.PatchPath(index)
	if err != nil {
		return fmt.Errorf("PatchPath: %v", err)
	}

	os.MkdirAll(filepath.Dir(patchPath), os.ModePerm)
	if err = ioutil.WriteFile(patchPath, patch, 0644); err != nil {
		return fmt.Errorf("WriteFile: %v", err)
	}

	return nil
}
895820
func (repo *Repository) PatchPath(index int64) (string, error) {
	if err := repo.GetOwner(); err != nil {
		return "", err
	}

	return filepath.Join(RepoPath(repo.Owner.Name, repo.Name), "pulls", com.ToStr(index)+".patch"), nil
}
1002837
func (r *Router) Patch(pattern string, handler http.HandlerFunc) {
	r.AddRoute(PATCH, pattern, handler)
}
289589
func (r *Router) PATCH(path string, handlers ...HandlerFunc) {
	r.Handle("PATCH", path, handlers)
}
550427
func (c *CommitFile) GetPatch() string {
	if c == nil || c.Patch == nil {
		return ""
	}
	return *c.Patch
}
565199
func (g *routeGroup) Patch(path string, h http.HandlerFunc) {
	g.handle(http.MethodPatch, path, h)
}
358894
func (r *SubRouter) PATCH(route string, handler interface{}) *SubRouter {
	route = r.prefixedRoute(route)
	if r.parent != nil {
		r.parent.handleReg(MethodPATCH, route, handler, r.prefixes)
	}

	return r
}
447641
func (r *Router) Patch(path string, fn http.HandlerFunc) *Router {
	return r.Method(http.MethodPatch, path, fn)
}
449589
func (r *Request) Patch(url string) (*Response, error) {
	return r.Execute(MethodPatch, url)
}
1038953
func (p *PullRequestLinks) GetPatchURL() string {
	if p == nil || p.PatchURL == nil {
		return ""
	}
	return *p.PatchURL
}
244677
func (e *Echo) Patch(path string, h interface{}, m ...interface{}) {
	e.add(PATCH, "", path, h, m...)
}